Kai-Uwe Schmidt wrote : | Hi folks, | | i have a server process which collects socket connects from clients. Those | connects are stored in a chain. On a special event on the server, the | process has to deliver some data to the clients. So far so good, but.. | | how do i recognize when i client disconnects, or how can i check the state | of the socket ? my process crash when it tries to send/write data on the | old-socket handle. it all written in C, so there is no way to use stuff | like try() catch() and i dont beleave, i should write an own signal handler | for this write/send statement. there must be a clean way to check/monitor | the state of the socket, but how ? You can determine if a socket is closed if a read from a socket that says there is data (via select) returns a number of 0 bytes on a read. There is also a trick reading zero bytes from the socket (that won't block and can be done at all times) and then checking the the nr of bytes written. I don't know exactly how to do it but try something like this to find out : unsigned char c; int res; res = read(socket,&c,0); printf("%d\n",res); i think res will be negative if socket is not available anymore (you might even be able to check errno to see what happened). Grtz Dries -- <End of message>