Jump to content
  • Advertisement

Archived

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

TheTempest

Small question about packet format...

This topic is 5913 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, background info: i''m using win32, async sockets... i can connect, recv, send, accept, close sockets // psuedo code struct packet1 { char userName[30]; char userPass[30]; } //size 60 bytes struct packet2 { int playerX; int playerY; } // size 8 bytes i know to send the struct you would do this: send(socket,(char*)&packet1,sizeof(packet1),0); but, if the server is blind, how can it distenguish between the two packets? I.E. i have read a tutorial on how to build a HTTP server/client, and the server and client can distuenquish between the two because they read the char arry to find sentienals. but u can''t do that w/ints... Any help would be greately appriciated, and i''m sure its something simple i can''t think of or find THX

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
You need to send an identification with every packet you send, so the server knows exactly what it is trying to receive. A good idea is to have the size, and type of a packet at the start of every packet. First the receiver reads the size, and then reads that many bytes from the network. Then it can look at the type id of the packet it has just read in, and then blind cast it to the proper struct.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!