Archived

This topic is now archived and is closed to further replies.

EasyGino

Socket Question Part Three

Recommended Posts

Ok, hopefully this will be the last time. I''m making a small 2d tank sim and in a nutshell the socket portion simply sends the tanks (id, x, y and direction) to the server and the server bounces all that information back. Now currently inside my winmain, and inside the switch(msg) I have a recieveMessage function I call which basically recv''s socket messages. The problem is, this runs and after a few movements, which both tanks move,(which is right) the program comes to a screeching halt. *note* to parse the recievebuffer from the socket I have a tokenizer function which basically strtok''s the id, x, y and direction for me. And all this seems to work for a couple moves and then halts. I know the send code works fine because I can watch the server recieve all my movement code, but once I try to recieve the echo''d coordinates, 1,2,3 crash. I''d show everyone the code but i''m at work right now.

Share this post


Link to post
Share on other sites
You have to devise a little mini-protocol that wraps your data. Simply a header that tells the client how much data it should expect in a single message should suffice for most purposes. This way you don''t start parsing until you know all the data has arrived.

Share this post


Link to post
Share on other sites