Not sue if this is correct thraed. but could any one help me?
What i am trying is, to detect the Connection reset by peer in order to hanlde it correctly.
What i observed is that "send" socket call is not returnuing "WSAECONNRESET" when the server is shutdown. I do get the error "WSAECONNRESET" after perfroming multiple sends. till then it is returning No error. Could any one tell me how to get the error first time?
i am using windows sockets.
Peer is another program and i cannot access the code for t.
Basically , i am working on client to send data to the server. the server is running on other machine. When i switch off the server pc , and and send some data from client, i am expecting the send should fail and return "WSAECONNRESET". but this is not happenning and i am getting "no error" for two or three times (3 sends) and then i am getting 'WSAECONNRESET".
Well, if the server simply closes the socket, then the client doesn't know about it until its sends fail after a certain timeout. If the server calls a shutdown, the server basically tells the client it is closing the socket first so the client can handle it gracefully.
You could set the wait timeout on your sending socket to a much lower value. If you are (as it sounds) working on a local network, then you can set your socket timeout really low so that send failures due to socket closure by the server will fail rather quickly and you'll get your send errors sooner, avoiding unnecessary waiting. There are a couple of ways to do this: my preferred method is to use select(),but there's setsockopt() with SO_RCVTIMEO or SO_SNDTIMEO.