Advertisement

Need help with detecting socket disconnection

Started by March 12, 2006 02:54 AM
1 comment, last by dave 18 years, 11 months ago
Hi, I'm developing a server using c++ blocking, multithreaded and multi-client socket(Winsock) programming. My problem is when the client got a connection disruption, the server won't automatically detects it and keep receiving data from the client. I'm curious why can't it auto detect since this is a blocking connection. Is it because of the multithreading? Anyway, I tried to detect the disconnected client by adding the client socket into a list array and then detect with a recv using a timer. I managed to detect the disconnected client by this way but when i try to close the socket, the program will crash. I think the reason for this is the socket is still receiving data in another thread. I don't want to close my listener socket just because of 1 disconnected client. Please help me.....
You should be pinging each client ver regularly, when you don't get then reply you know something is up.

Dave

This topic is closed to new replies.

Advertisement