I've got a client and server program communicating over a stream socket. They are C programs compiled using gcc running under Linux.
The server calls socket(), bind(), listen(), then loops round calling accept() and creating a thread to read() messages on the connection. The thread exits when the read() returns 0 (indicating EOF on the socket). The client calls socket() and connect() to connect to the server, then write() to send messages to it. This all works fine, until I stop the programs using CTRL-C. Then when I re-run the server I sometimes get a 'address already in use' returned by bind(). However, if I wait a minute or 2, it's ok again. I guess it's because I'm not closing down the socket properly or something. I'm no socket expert - what am I missing out? Cheers John
