Jump to content
  • Advertisement
Sign in to follow this  
Anddos

3 Questions on my mind about (winsock)

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

Question 1:
I am using TCP (WINSOCK)
 
Client 1 connects to server (Desktop pc)
Client 2 connects to server (Desktop pc)
Server (laptop console based application as gui dosent matter in this case)
 
Server recieves both connections
Client 1 moves forward
Client 2 moves forward
 
How do you tell the server to only send back the clients2 movement back to client 1 and not make 
the server send back Client1s movement from the server back to client1,that seems like a waste of 
bandwith to me?,do you have to give each connection an id or something and test do a condition server side?
 
Question 2:
Should i be using a multithread server so that when there is a connection to the server a new 
thread is spawned to handle each clients communications,or is there another way todo it?
 
Question 3:
 
There is something interesting in one of my programming books,basically the guy is like queuing 
packets and putting them back in order what is that for?
 
I think thats everything thats been on my mind covered smile.png
Thanks for reading.
Edited by Anddos

Share this post


Link to post
Share on other sites
Advertisement

1. Yes identify your clients. Usually a server has more than one game at a time. So besides "not mirroring client 1 back to itself", it's also about "not sending client 3 which is in another game" back to clients 1 and 2.

 

2. You can use asynchronous io. Look up TCP IO selector on google. It can handle many connections on a single thread. The problem is that It is more difficult then using threads, so if you only have less then 10 connections at a time, don't think about it and keep using threads.

 

3. Some people like to use UDP instead of TCP for multiplayer. It is much faster than TCP, and you can also broadcast to more than one player at a time. The problem is UDP packets can arrive out of order, so you need to re-order them. If you are using TCP, don't worry about it. TCP is basically a high level protocol over UDP that includes ordering and error handling. If you are making a realtime game, I would turn on TCP_NODELAY to prevent TCP from delaying transmission of your data. These delays can reach several 100s of milliseconds.

Edited by SillyCow

Share this post


Link to post
Share on other sites

For Question 1  --

 

a) Just because client 1 sends a command to move forward doesnt mean it gets received  in time to move forward in that cycle/turn of the servers processing. That might come later in time (next turn...).   Of course, if the turn around period is long the client may visibly move itself anyway and once confirmation from the server comes in then it can procede (or if some unexpected thing happened it would have to undo/adjust what it originally projected)

 

b) depending on what visibility rules your game mechanics use,  the move data for client 1 may NOT need to be sent to client 2 if it is calculaterd (at  the server) to be out of visibility to client 2.    On big worlds that is done alot.

 

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!