Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.protocols.tcp-ip    |    TCP and IP network protocols.    |    14,669 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 13,848 of 14,669    |
|    Rick Jones to yzghan@gmail.com    |
|    Re: recv hanging    |
|    22 May 12 18:00:42    |
      From: rick.jones2@hp.com              yzghan@gmail.com wrote:       > Hi all, I've run my application into an issue with recv() hanging       > while the server already exited. recv() is not returning any data or       > error. More puzzling is that netstat shows on client side the       > connection in ESTABLISHED state while on server side netstat reports       > no such connection. Can someone shed some light or share any       > experience on this? Below is my system info. Many thanks.              If the server side manages to "go away" without the client TCP seeing       it happen then you can indeed remain in a recv() call forever. For       example, if the server simply crashed, or if the server application       closed and the TCP FIN segmen and its retransmission was not received       by the client TCP.              TCP by default only runs timers when it is actively transmitting data       to the remote, so if there is no data still being transmitted to the       server, there are no timers running and so the recv() can stay there       forever.              There are a number of possible solutions:              1) Mark the socket non-blocking and use select()/poll()/epoll() with a        timeout that matches what your application requires.              2) Use setsockopt() to set SO_RCVTIMEO if all the stacks on which you        want your application to run support it.              3) Set SO_KEEPALIVE to cause TCP keepalives to be enabled. This will        cause TCP to send keepalive probes and so be able to detect        (eventually, by default it won't start probing for two hours) the        inability to reach the remote system.              I believe this topic is covered in various texts such as Stevens,       Fenner and Rudoff's "Unix Network Programming" and the works of       William Stallings among others.              rick jones       --       firebug n, the idiot who tosses a lit cigarette out his car window       these opinions are mine, all mine; HP might not want them anyway... :)       feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca