Re: receiving data with soreceive
Re: receiving data with soreceive
- Subject: Re: receiving data with soreceive
- From: Bijoy Thomas <email@hidden>
- Date: Sat, 14 May 2005 21:24:50 -0400
I tried using MSG_PEEK with soreceive and it does return the actual
number of bytes that the server has sent. So i guess making a soreceive
with MSG_PEEK followed by a soreceive call with uio_resid set should
return whatever data the server sent.
I also tried the following code
do
{
auio.uio_resid = 20;
result = soreceive(sock,NULL,&auio,&m,NULL,&flags); //flags =
MSG_DONTWAIT
} while ((auio.uio_resid == 0) || (auio.uio_resid == 20));
But i guess this would just loop if the server sent exactly 20 bytes.
Regards,
Bijoy Thomas
On May 14, 2005, at 6:59 PM, 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. 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.
Bijoy: Definitely get Stevens' TCP book as Justin recommended -- this
is all covered in detail.
Brian Bergstrand
<http://www.bergstrand.org/brian/> PGP Key ID: 0xB6C7B6A2
-----BEGIN PGP SIGNATURE-----
Version: PGP Desktop 9.0.1 (Build 2130)
iQA/AwUBQoaC6nnR2Fu2x7aiEQJsJQCgjVA6tN8qdfqP9RS2KQiqiTrFvyUAnjcd
AwNZPhnBaZUJWlvQIchE6kRa
=zVVH
-----END PGP SIGNATURE-----
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
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