944,001 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 13831
  • C++ RSS
Oct 12th, 2004
0

Create Socket server and client?

Expand Post »
Hi, I am new to C++

I am working with C++ .NET to create a multiplayer game for a project. However I need to connect the multiple computers together, for it to work, with one computer acting as the server and the other (max of 6 others) connecting to it as clients.

I would like to know how to create a multi threaded server and how to connect to it via sockets.

I have very limited experince with sockets in Java, but none in C++.NET, The way the system will work is, the Host listens for connections, players connect, and are logged as having joined, Host player will click play which will send a message to all other players computers to load the play screen, players will make there moves then after 5 minutes or after each player has clicked on OK the moves will be sent back to the server pc where they are checked, the results are then sent out to each pc and then the next turn is started.

Any help would be much appriated, I hope this is enough info to get you started on advise, if you need any more info please ask. The game will be played on modern windows computers only at this stage.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
gamesnmore is offline Offline
4 posts
since Oct 2004
Oct 7th, 2005
0

Re: Create Socket server and client?

You can do this in a few different ways. I don't know windows, so some of the following ways might not work, or might be different.

You can listen for a connection and accept it, then fork out the processess. I dont think windows does this, but it can be a resournce hog.

So, you can thread out the processess. This is a lot faster and kinder on resources.

With a threaded process you can access all global variables, which makes it easier to communicate between connections.

Again, I dont know anything about windows programming so I would recommend reading whatever socket API windows uses. If I remember correctly its the winsock API.
Reputation Points: 10
Solved Threads: 0
Light Poster
calcop is offline Offline
27 posts
since Oct 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: C++ questions, How do they do it?
Next Thread in C++ Forum Timeline: where to get C compiler





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC