LWN.net Logo

OT

OT

Posted Mar 28, 2006 21:10 UTC (Tue) by tjc (subscriber, #137)
In reply to: OT by guinan
Parent article: The Grumpy Editor's guide to RSS aggregators

You have to keep track of the number of bytes returned and make multiple attempts. [snip] I usually write a wrapper function around recv() to keep the calling code simple.
Thanks for the reply. Would you mind sharing this wrapper function? It would save me some debugging time.


(Log in to post comments)

OT

Posted Mar 29, 2006 20:24 UTC (Wed) by guinan (subscriber, #4644) [Link]

I don't mind sharing, but are you writing in C, Python, other?

Do you know ahead of time how many bytes you want to receive?

If the length is embedded in the data stream, you might as well recv() as much as you can, to avoid extra system calls. But if there's another message behind the first one, you might end up reading into that, in which case you should keep ahold of the "remainder" for the next call.

Email me guinan@bluebutton.com if you want to take it offline.

Copyright © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds