Jump to content
  • Advertisement
Sign in to follow this  
DvDmanDT

Advice please?

This topic is 4849 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

Hello everyone.. I'm making an RTS, with a client-server model.. It will work by sending game-messages.. Pretty simple and straight forward.. Each client will send their messages to the server, which will then send it back and to all other players as well (so that the game runs synchronized).. So.. I should use non-blocking sockets for this, right? Or blocking with threads? Oh, and is there any way to know how much data can be read from a socket? I will be sending fixed size messages, of say 256 bytes each, and I would like to know if an entire message is recieved and ready to be read, or if I should wait another frame or two for it to get recieved.. More coming at a later point.. All help is appreciated..

Share this post


Link to post
Share on other sites
Advertisement
Personally I do not prefer multithreading so I recommend using nonblocking sockets, unless you use selecct () and then it doesn't matter if they are blocking or nonblocking...
to see how much data has been recieved until now in your socket you should call recv (sock, buffer, length, MSG_PEEK); this will only check what there is now in the socket and copy it to the buffer and return the number of bytes currently availble, but it will also not delete the data from the queue so if u do recv again you will get the same data again. you can just wait until recv returns 256...

Share this post


Link to post
Share on other sites
Ok, that was my initial thought.. Altough, it seems like a rather ugly way to do it.. .. Guess I'll go with that for now though.. Thanks.

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.

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!