timeout socket python

socket.settimeout(10) # sets the timeout to 10 sec

Here is what the above code is Doing:
1. Create a socket object
2. Get local machine name
3. Reserve a port for your service
4. Bind to the port
5. Put the socket into listening mode
6. Wait for client connection
7. Establish connection with client
8. Send data to client
9. Close connection