Fix Python – socket.shutdown vs socket.close

I recently saw a bit of code that looked like this (with sock being a socket object of course):

What exactly is the purpose of calling shutdown on the socket and then closing it? If it makes a difference, this socket is being used for non-blocking IO.

Fix Python – On localhost, how do I pick a free port number?

I’m trying to play with inter-process communication and since I could not figure out how to use named pipes under Windows I thought I’ll use network sockets. Everything happens locally. The server is able to launch slaves in a separate process and listens on some port. The slaves do their work and submit the result to the master. How do I figure o….