Re: socket write gets stuck
Re: socket write gets stuck
- Subject: Re: socket write gets stuck
- From: Larry Gerndt <email@hidden>
- Date: Wed, 19 Mar 2003 21:48:54 -0800
Homer and Mark, I'm posting this question to the Apple developer's forum,
thought you might be interested and maybe even have some ideas.
On 3/19/03 9:47 PM, Larry Gerndt wrote:
>
My Carbon/CFM application is a client in a client/server suite. For
>
networking, on OS X I use the socket API. It works great, but I've run into a
>
problem:
>
>
Recently our server engineer made a mistake on a timeout parameter involving
>
the socket, and this resulted in my client's socket write() to hang, and
>
eventually this resulted in me crashing (due to not properly terminating
>
threads). Well he quickly fixed his error but I asked him to un-fix it again
>
so that I can improve my code to handle such a situation gracefully if it ever
>
occurs in the future.
>
>
I'm not sure exactly what was going on at the server side of this socket, he
>
said something like: "I accidently set the read thread's timeout to zero
>
thinking that would be infinite, but it was really zero." (sorry but I don't
>
know more than that). Anyway, if I attempt to write a large chunk of data to
>
the socket when it's in that condition, it gets stuck (and stays stuck). For
>
some reason smaller chunks are ok.
>
>
I figured if something was wrong on the server side of the pipe, my write
>
should have returned an error, but then I heard that if you don't tell BSD to
>
ignore SIGPIPE, your write() will not return, instead a SIGPIPE is generated.
>
So now I *do* tell it to ignore SIGPIPE, but the behavior is the same. I
>
scratched my head, then thought, well at least I should be able to implement a
>
time-out on write(). So I set up a 5-second timeout on write() via a call to
>
setsocketopt(). No timeout ever occurs. This bug is like a rock that I can't
>
so much as budge. Does anyone have any insight to share?
--
Larry Gerndt
AIM Handle: thesonofmannn
Let the truth be told though the heavens fall -- James Garrison
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.