Jump to content
  • Advertisement
Sign in to follow this  
Civilwar

Winsock - Sending structs of different size

This topic is 2604 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,
I am using WinSock library for sending data over network, and I have a problem.
I know how to send data in one struct and receive it on the other side, because there is constant size of structure. But what if I have more structures, each one with different size?
Now I have one struct that contains locations of players and other with in-game messages. When I am about to receive struct, I don't know which one is being sent.
Is there a "trick" how to do that?

Thanks for help.

Share this post


Link to post
Share on other sites
Advertisement
Usually you send an id either before the structs or as the first part of each struct. Read the id and use that to determine how much to read.

Share this post


Link to post
Share on other sites

Usually you send an id either before the structs or as the first part of each struct. Read the id and use that to determine how much to read.


Could you give me a code snippet? I tried it, but I received wrong data, so I thought it can't be used that way.


Btw, I am using asynchronous sockets.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!