in reply to Socket problem

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.

Replies are listed 'Best First'.
Re: Re: Socket problem
by Marcello (Hermit) on Jan 30, 2003 at 12:50 UTC
    That is just the problem, if a client for whatever reason disconnects (closes the socket with the server) instead of closing the connection properly, the server still assumes the connection is active. And this is what I want to detect so I can stop the forked process.

    Regards, Marcel
      If you're reading from the socket, and using IO::Select->can_read() to see if data is available, then when the other side disconnects, can_read() indicates that there is data to be read, but the data read is empty. Thats how I tell if a socket is closed. (The data was an EOF, I remember reading somewhere.)

      C.