| | |
Create Socket server and client?
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
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 beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy desktop developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker list loop looping loops map math memory multiple news node number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference rpg sorting string strings struct temperature template test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





