Re: how do I call soreceive?
Re: how do I call soreceive?
- Subject: Re: how do I call soreceive?
- From: Josh Graessley <email@hidden>
- Date: Mon, 9 May 2005 13:23:01 -0700
On May 9, 2005, at 1:13 PM, Bijoy Thomas wrote:
<snip>
If we are using a tcp socket, do we need to provide the second arg
for soreceive or is that only for udp sockets.
I think it's optional. The source code is available, so if you're
really curious you can dig through the function yourself. It's a
little complex, but not nearly as daunting as sosend ;)
Am i correct in my assumtion that as long as i care only about the
data, i just need to provide the struct uio arg for sorecieve with
its iovec filed initialzed to my kernel space buffer and its length
and setting uio_segflg = UIO_SYSSPACE and uio_rw = UIO_READ. In
this case the mbufs can be NULL in the call to soreceive.
If you fill out the uio with information on where to store the data,
you can leave the mbuf NULL. If you want to receive the data in an
mbuf chain instead of having the data copied in to your buffer, you
could do this by just specifying the uio_resid and fill out the mbuf
parameter.
Also, why do we use the uio_resid field in the struct iuo? Is it
used in multiple calls. Can we just set it to the buffer length on
the first call?
You can use this value to determine how much data was received. Set
it to the maximum size of your buffers when you call soreceive. Keep
a copy of what that value was. Upon return, you can retrieve the
value again then subtract that from the original to determine the
amount of data received. This value is also useful for limiting the
maximum amount of data to receive in an mbuf chain.
I was using the flag MSG_WAITALL for the soreceive. Will that cause
the soreceive to stall until all data arrives? Is there a default
flag for just returning whatever data has arrived.
soreceive behaves the same as recvmsg in userspace with respect to
waiting.
-josh
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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