| | |
Create Socket server and client?
![]() |
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.
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.
•
•
Join Date: Oct 2005
Posts: 27
Reputation:
Solved Threads: 0
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.
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.
![]() |
Similar Threads
- Most efficient "real-time" system. Socket Server or Client Queries (PHP)
- strange signs server->client connection with select() (C++)
- Regarding client-server ??? (C++)
- php socket server - can't connect from flash xml client socket (PHP)
- Single-server, multiple client ActiveX (Visual Basic 4 / 5 / 6)
Other Threads in the C++ Forum
- Previous Thread: C++ questions, How do they do it?
- Next Thread: where to get C compiler
| Thread Tools | Search this Thread |
api array based binary bitmap c++ c/c++ char class classes classified code coding compatible compile console conversion count date delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file filewrite forms fstream function functions game givemetehcodez graph gui homeworkhelp homeworkhelper homeworksolutions iamthwee icon if...else ifstream input int integer java lib linkedlist linker loop looping loops map math matrix memory multiple news node object output play pointer problem program programming project python random read recursion reference rpg string strings struct symbol temperature template test text text-file toolkit tree url values variable vector video win32 windows winsock wordfrequency wxwidgets





