• 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
CFSockets, sockets and timeouts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CFSockets, sockets and timeouts


  • Subject: CFSockets, sockets and timeouts
  • From: Nicolas Berloquin <email@hidden>
  • Date: Sun, 11 Apr 2004 22:53:27 +0200

Hello !

To set the context a bit: I'm connected to many distant peers, to whom I regularly send a stream of
data. I need to know at the time of the sending that the peers's pipe is full or blocked.

I've been struggling a bit with CFSockets and non-blocking I/O and I ended up using a mix
of hand-created native tcp sockets that I feed to CFSockets (so that they can be handled transparently
by cocoa and its socket wait-loop thread, and then call my read callback when data is available).

I tried CFSocketSendData, then send() with message options like MSG_DONTWAIT but I still got
blocked until data was sent (to be more precise when the tcp send buffer was full, I guess).

So I had to set the timeout option on the sockets themselves with :
err = setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));

now, here comes my question:

I tried different values for timeout, but I'm not sure what would be the best.
I'm sending data to a list of distant peers, and I don't want to waste any time waiting if a peers'
pipe is still full, but I don't want to set a value too low for the TCP stack itself to handle.
I tried values ranging from 20ms to 10 microseconds.
How low can I set it so that my thread isn't blocked ?
Does the timeout take in account time to buffer it ?
If I set a very low timeout, will data still be queued in the TCP send buffer ?

thanks for your hints ^_^
_______________________________________________
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.


  • Follow-Ups:
    • Re: CFSockets, sockets and timeouts
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: AFP tuning
  • Next by Date: Re: CFSockets, sockets and timeouts
  • Previous by thread: Re: AFP tuning
  • Next by thread: Re: CFSockets, sockets and timeouts
  • Index(es):
    • Date
    • Thread