| David Schwartz 2008-03-20, 7:15 pm |
| On Mar 20, 2:00 pm, jiangxu...@gmail.com wrote:
> I am calling function recvfrom() with flag set to MSG_WAITALL.
> I thought the function is supposed only to return when the buffer is
> completely filled up, or when there is a signal or error occurs.
It returns when the entire message is received.
> However, in my experiment, the function constantly returns with fewer
> number of bytes than requested. The returned size is always the same
> as the payload size of one multicast ip packet. I wonder why?
Because you have received the entire message. In a datagram protocol,
each datagram is a message.
> Is there a way to make the function (or use other function) only
> returns when the buffer is completely filled up if there is no signal
> or error occurs??
No.
> Baically I don't want frequent context switch
> between kernel and user space. What I want is to accumulate certain
> amount of the ip multicast packets before the function returns. I am
> working on Linux 2.6.
Don't worry about it. You will only get frequent context switches if
there's nothing else to do. If there's nothing else to do, why should
you care if there are lots of context switches?
DS
|