My guess is that you're just killing the client programm. If you look at the contents of 'netstat -a' after that, you'll see that the connection itself stays up a while, probably depending on what you set your Timeout to when starting up.
It's probably a better idea to get the client to send 'quit' or something, and read data from the socket in your loop, quitting when you see 'quit'.
C.