Re: Posted read() hangs on socket disconnect
Re: Posted read() hangs on socket disconnect
- Subject: Re: Posted read() hangs on socket disconnect
- From: Jens Alfke <email@hidden>
- Date: Wed, 27 May 2009 16:46:22 -0700
On May 27, 2009, at 4:32 PM, Jonathon Kuo wrote:
The receiving process uses a read() posted on a socket that reads
small data packets in a loop. It works fine until the sender quits
(disconnects/aborts). I was expecting the posted read() call to
return with a status < 0, but it never returns, it just hangs forever.
If the sending process closes the socket, exits or crashes, then the
socket will be closed on the receiving end too. I would think the read
call would return immediately, with errno==ECONNRESET, but I'm
somewhat sketchy on the low-level POSIX network APIs.
On the other hand, if the sending machine is abruptly disconnected
(Ethernet unplugged, power failure, kernel panic...) then the receiver
never gets notified that the connection's closed, and so it will end
up waiting for a very long time, like 90 minutes, before giving up and
deciding the socket's closed.
—Jens [Ricketts Hovse '87]
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden