Hello guys!, Could anyone tell me how can I flush a IP buffer?...I have a client-server application. The client sends data normaly, but when the server gets down suddenly (a reset), the client appears not to realize that the connection is down and keep on sending. This makes that the ip buffer get colapsed. In this situation, the other threads of the aplication, as the one sends pings every second, can not send messages. The problem is that the "send" function return me the "ENOBUFFS" error when the IP buffer is full instead of the sockect buffer. Is there any way to know when a socket buffer is full to close the connection a flush the IP buffer without wait for the confirmation from the other side of the comunication, which is allready down!
Thank you in advance.
Hi , I am in no way an expert on this subject, but it sounds to me like you need some sort of timeout on the client side. Just thinking the problem out, I think you will want to create a thread (A) that will create another thread (B) to make a request to the client. Thread B will be an asynchronous thread meaning thread A will not wait for it to return when it creates it. Thread A will start a timer as soon as it creates thread B. Thread B will have a reporting mechanism to indicate to thread A when a request has completed which will stop the timer in thread A. If the timer in thread A counts down to zero, or up to the timeout limit, then thread A will communicate to thread B that it has timed out and whatever resources being used for the request will be cleaned up. I hope this helps. And please, if you are reading this and know I am completely wrong, please speak up. Thanks!
So I was completely wrong, as I had suspected. I was just talking the problem over with a friend, and he says that you need to do more error handling. He says that you will receive a zero, or -1 once you try and send data and find that the connection is no longer good. In addition (and this is just some info I looked up) you don't have to create multiple threads to create a timeout mechanism. It looks like there is a function 'setsockopt' that will let you set timeouts on the socket for sending and receiving information. The option is 'SO_RCVTIMEO' and 'SO_SNDTIMEO' .