Advertisement

something i never understood about winsock

Started by September 18, 2003 09:27 PM
2 comments, last by fireking 21 years, 4 months ago
something i never understood about winsock is packet division everyone knows that when they sit down with winsock (and use tcp) they want to send a message, and receive that entire message on the other end. The best method for doing this is sending a header along with the packet (or message or whatever) to describe what kind, and how big... well, if winsock has the ability to take anything you send and break it up into as many peices as it wants, what if the header is broken up into peices? then how do you know how long the message is, and how many times to recv and if you tell me that header''s are never broken up, then why cant you send all your data in a header and never worry about your stuff being broken into tons of peices? if someone could demistify this, id be a very happy man
--FirekingOwner/LeaderFiregames Development &Blackdragon Studios
The answer is deceptively simple. Your header is always the same size, so you can easily check if you''ve received all of it yet or not. Once it''s fully received, then you can interpret its payload accordingly.
Advertisement
Yup, TCP is a STREAM, and should be treated as such... it''s like reading in part of a header of a file... if you read in 1/2 of it... keep reading until you have the entire thing, once you have the header filled, continue reading in the data until it''s received. I wrote an Active X control in VB that notifies me when a full packet is received (it''s as easy to use as the vb winsocks, but is guarenteed to be a full packet when it raises the event). Obviously, this isn''t to much use to my C++ engine, but I''m probably going to implement the same thing in my C++ game engine, only call the process packet even once a full packet is received.
ohhhhhhh

thank you both, one guy tried to help me through this same problem, and it took us about 3 pages to come to the conclusion that i was some sort of idiot or something

thank you again for helping me, i completely understand now
--FirekingOwner/LeaderFiregames Development &Blackdragon Studios

This topic is closed to new replies.

Advertisement