Unless you are using UDP and instead using TCP, you do not need to worry about fragmentation: MS TCP layer would handle it and Winsock will just fill your buffer--the size you want. There is one exception: the last packet. You should check for connection termination and packet sizes of smaller than buffer size, most notably <= 0.
Regards, SZ ----- Original Message ----- From: <[EMAIL PROTECTED]> To: <twsocket@elists.org> Sent: Saturday, December 17, 2005 10:05 AM Subject: [twsocket] socket programming tcp/udp primer question >I recently read the tcp/udp primer under the overbyte.be "support" section > and the tcp data fragmented packet example using the text string "Hello" > caught my attention because that is something i always wondered about in > socket programs. The fact that the data can be split up into multiple > packets coming in fragments like "he" "l" "lo" is something i'd like to > know > how to handle properly. What i mean by this is if i'm expecting the line > "hello" and i'm parsing TCP receive socket data i need to handle "hello" > as > a whole word without the fragmentation causing my parser to fail and pass > the data on without proper handling. I'm wanting to write a chat client > for > icq/aim/irc/yahoo or any other major protocol and none of the protocols > have > set boundaries that are apparent to me. Some end on a series of NUL chars > (#0) in Delphi or a numeric (a given number) and so on... I'm pretty new > to > sockets and i need some advice from the more experienced users which would > be you guys. If i'm expecting a 2 KB packet char for char that's using TCP > protocol and is guaranteed always to be there no exceptions (enforced > strictly through the protocol implementation) how can I force WSocket's > OnDataAvailable event to queue the data until it's assembled into one > large > chunk so i can then process it as if it all arrived that way instead of > split up. I'm aware that I will have to set my own boundaries on the > begining of the expected data and the end of the packet data so that i can > get the big picture and make sure i process it as I need but is there any > method you would recommend to force the socket to wait until the rest of > the > data comes in? Would calling wait() and peeking the data not help at all > or > would the buffer be overwritten during the wait period instead of > concatenated with the data coming in afterwards? Can i see an example by > chance or get a professional opinion. > > -Brad > -- > To unsubscribe or change your settings for TWSocket mailing list > please goto http://www.elists.org/mailman/listinfo/twsocket > Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be