Expecting entire packet in one Socket read - General Discussion - Netduino Forums
   
Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Expecting entire packet in one Socket read


  • Please log in to reply
1 reply to this topic

#1 Cabadam

Cabadam

    Advanced Member

  • Members
  • PipPipPip
  • 90 posts

Posted 19 February 2012 - 02:53 PM

This question stemmed from reading a new HTTP server implmentation posted over here: http://forums.netdui...her-web-server/ It made me realize I've seen a common thread in most (all?) of the HTTP server implementations I've seen for the Netduino. They all seem to just do a single read off the socket in order to get the request. But... what if it takes more than one? In non-netduino applications for work (Windows Server 2003/2008 environments), I've seen what should be one 16-30 byte packet come to us as one byte at a time (so we had to call "Read" 16-30 times, appending to a buffer, looking for the appropriate packet terminator or byte count, depending on the protocol). Admittedly, one byte at a time is the extreme case, but I have seen it happen. It all depends on what is on the other end talking to you, and the network topology in between. But like I side, I don't think I've seen a single HTTP implementation which takes that into account. The one I'm currently using does not. I also do not think I've seen the problem expose itself to me. Maybe this is just because the Netduino's typical environment (home WiFi/ethernet networks) are a bit more reliable than the field-networks I interact with at work (which may include RS232/RS485 or fiber segments mixed in)? I guess I'm trying to decide if this is really a concern worth trying to implement. Thoughts?

#2 Cuno

Cuno

    Advanced Member

  • Members
  • PipPipPip
  • 144 posts
  • LocationZürich / Switzerland

Posted 19 February 2012 - 06:54 PM

But like I side, I don't think I've seen a single HTTP implementation which takes that into account.

It's certainly not correct to assume that a complete request can be consumed in a single receive operation. We also have seen situations in real life where bytes trickled in one by one. I already wondered whether typical Netduino environments don't suffer from this problem in practice, or the problem is simply rare enough that no one appears to be affected.

But for the record, my Web server for Getting Started with the Internet of Things takes this into account (content section of method Gsiot.Server.HttpServer.HandleRequest) ;)

Cuno




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.