Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

socket programming using MSG_WAITALL for receiving multicast packets
Hi,

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.

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?

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??  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.

Thanks in advance!

John

Report this thread to moderator Post Follow-up to this message
Old Post
jiangxu168@gmail.com
03-21-08 12:15 AM


Re: socket programming using MSG_WAITALL for receiving multicast packets
In article
<25d3af5a-ffeb-422c-8e69-e44bf97926df@t54g2000hsg.googlegroups.com>,
jiangxu168@gmail.com wrote:

> On Mar 20, 4:11_pm, David Schwartz <dav...@webmaster.com> wrote: 
>
> I am receiving high bit rate streamming data such as Video data.  I
> think it will be more efficient with less context switch between
> kernel and user space.  So if the kernel can accumulate more packets
> before wake up the function, it should be more CPU efficient, right?

Regardless, there's nothing you can do about this.  With datagram
sockets, there's always a one-to-one correspondence between datagrams
and calls to recv.  How else do you expect to tell where the datagram
boundaries are?

The MSG_WAITALL option is only meaningful for stream sockets, since
there are no datagram boundaries to worry about.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE don't copy me on replies, I'll read them in the group ***

Report this thread to moderator Post Follow-up to this message
Old Post
Barry Margolin
03-21-08 12:15 AM


Re: socket programming using MSG_WAITALL for receiving multicast packets
In article
<fff08a99-f817-48d3-acd9-58707f90b390@e6g2000prf.googlegroups.com>,
David Schwartz <davids@webmaster.com> wrote:

> On Mar 20, 4:23 pm, jiangxu...@gmail.com wrote:
> 
>
> Don't worry, the scheduler agrees with you. When efficiency matters,
> there will be less context switching.
> 
>
> Right, and that's exactly what the kernel will do, all by itself.
>
> If you test with no load, you will get lots of context switches. This
> is fine -- you can't save CPU in a jar to use later. As soon as the
> load goes up, the system will spend time doing other things and by the
> time your process gets to run, more packets will be accumulated as if
> by magic.
>
> Don't try to "fix" the scheduler. It's not broken.

What does the scheduler have to do with this?  He's not talking about
process switches, he's talking about context switches between user and
kernel mode when calling recvfrom().

There is overhead when going into and out of the kernel, but in this
case there's nothing you can do about it.  There's no system call for
getting the datagrams that have been buffered all at once.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE don't copy me on replies, I'll read them in the group ***

Report this thread to moderator Post Follow-up to this message
Old Post
Barry Margolin
03-21-08 12:15 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Unix Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 01:59 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.