• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: socket write gets stuck (SOLVED)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: socket write gets stuck (SOLVED)


  • Subject: Re: socket write gets stuck (SOLVED)
  • From: Larry Gerndt <email@hidden>
  • Date: Thu, 20 Mar 2003 08:28:53 -0800

Update: I got the timeout working. When I checked the return value of
setsockopt(), I saw "parameter error" and realized that I had mis-declared
my function pointer to setsockopt() (since I'm on CarbonLib, I have to get
function pointers to BSD functions). So the write() timeout *does* work
very well. I will go with that solution.

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.

  • Prev by Date: Re: Multiprocessor problem?
  • Next by Date: FHLP anyone know
  • Previous by thread: Re: socket write gets stuck
  • Next by thread: FHLP anyone know
  • Index(es):
    • Date
    • Thread