Re: socket “read” hanging if the MacBook sleeps more than 10 minutes
Re: socket “read” hanging if the MacBook sleeps more than 10 minutes
- Subject: Re: socket “read” hanging if the MacBook sleeps more than 10 minutes
- From: Jens Alfke <email@hidden>
- Date: Thu, 5 Nov 2009 11:05:23 -0800
On Nov 5, 2009, at 6:09 AM, Sabyasachi Ruj wrote:
Now, while the app is downloading, if I put the MacBook in sleep mode
for more than 10 minutes, 60% of the time the app hangs when the
computer wakes up.
...
Also, this is not just TCP/IP waiting that will come out in few
minutes. I have waited for more than 12 hours, it did not come out.
I'm not a TCP expert, but I think this is normal. If the sleep occurs
while the socket doesn't have any packets to send, or to send ACKs
for, then on wake it'll just be waiting for incoming packets that will
never arrive (because the server's already timed out and closed the
socket.) And TCP doesn't have any timeouts for idle sockets.
If what I'm saying is true, and you want to avoid this, you should
probably set a timeout on your read. And/or detect system sleep and
close the socket then (which is what apps like Mail and iChat do.)
—Jens _______________________________________________
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