For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > March 2008 > Re: socket programming using MSG_WAITALL for receiving multicast









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: socket programming using MSG_WAITALL for receiving multicast
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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com