Jump to content
  • Advertisement
Sign in to follow this  
hans-ola

server with multiple clients

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

Hej! At the moment i'm creating a turnbased game. The rules are somewhat like chess(but it's not chess). The first player roll a dice, move a brick and then it's the other players time to play. The game will also have a chat in it so you can comunicate with your oponent. I want to create a server for this, so that the first player that connects to the server will get a message "waiting for other player". When the second player enters, a game will start. When a third player enter he will get the message "waiting for other player" until the fourth player enters, and so on. This will be done by starting a new thread for every game. I'v done a chatprogram and a multiplayergame earlier, but then it was just 2 computers comunicating with each other(without server) and i had a connection open all the time. ------------------ THE PROBLEM; When 2 or more players connect to the server, is it possible for the server to have connections open for alla clients? What i understand only one socket can be open at the same time. If so, is this the best way, or should you close/open connection all the time? I'm using TCP socket programming. And the language i'm using is C#. [Edited by - hans-ola on April 21, 2007 7:57:28 PM]

Share this post


Link to post
Share on other sites
Advertisement
You have a single port open listening for incoming connections on your server, when a client connects you assign it a port for direct communications. I'm afraid I can't provide any info about working with C#, but I imagine it's fairly straight forward (it was relatively easy to setup nonblocking ports in C++ when I did it a couple of years ago, so it should be a snap in C#).

Share this post


Link to post
Share on other sites
On the server, you will be listening on port X. Each connection that opens up will return a new socket when you accept the connection. The server can have as many sessions open to the same port as you have memory (not quite true, but close enough).

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!