Re: receiving data with soreceive
Re: receiving data with soreceive
- Subject: Re: receiving data with soreceive
- From: Justin Walker <email@hidden>
- Date: Sat, 14 May 2005 16:16:33 -0700
On May 14, 2005, at 15:59, Brian Bergstrand wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On May 14, 2005, at 5:39 PM, Justin Walker wrote:
On May 14, 2005, at 15:22, Bijoy Thomas wrote:
Are you calling soreceive in an so upcall? If so, try setting
MSG_DONTWAIT in the flags, and that should give you everything that
is in the so buf at that point. MSG_DONTWAIT tells the socket not to
block. For the auio resid, use M_COPYALL.
This is an alternative, but keep in mind that using this means that
your code has to make sure all the data you need is in place,
essentially by reconstructing the incoming packet byte-by-byte
(i.e., you need to make sure enough bytes are present to form a
valid header so you can read the length, so you can make sure
enough bytes are present to process the rest of the packet, ....).
It also means you are polling for data, which may not be the best
idea.
Cheers,
Justin
Hmm, don't know where you got the polling from.
Sorry for the confusion; this was germane to MSG_DONTWAIT: if you
combine it with event-based notifications (i.e., wait for the next
little bit if there's not enough yet), you're correct - polling need
not be an issue (unless you have a notification for each byte; then it
could be painful).
upcalls are event
based, so when there is data to read (or the sock is ready for
writing) your upcall (callback) is called. If all of the data is not
in the socket at that point, you buffer it and wait for the next
event. No polling involved. However it does mean more work on your
part because everything is async.
Except for the above...in general, you're right, but one does have to
worry about failure modes and edge cases :-}
Cheers,
Justin
--
Justin C. Walker, Curmudgeon at Large
Institute for General Semantics
-----------
My wife 'n kids 'n dog are gone,
I can't get Jesus on the phone,
But Ol' Milwaukee's Best is my best friend.
-----------
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden