Multiplayer Game Server

Ok, so here I am again… months and months on this.

If you have a Server that listens for connections from a client and a client connects saying they wish to host a game, the server will launch a game on the server. Now how do you make it so that the client can communicate directly with the game, not through the server and make it so the game can communicate directly with the client, again not through the server?

Do you pass the server socket to the game and use a different port? Then tell the client what new port to use to talk to the game? I really dont think this method would be correct.

I really dont want the clients that are connected to games to have to send messages to the server, then have the server send the message to the game and vice versa.

Any suggestions would be greatly appreciated!

You can do a P2P like scheme where the server sends the players the addresses of other players, so that they can communicate within each other

So:

Player 1, with IP 1.2.3.4 connects to the server
Player 2, with IP 2.3.4.5 connects to the server

Server sends both players each other’s IP, and they can connect in a peer 2 peer fashion

you must program you clients to be able to listen to other clients

I appreciate that but ultimately I will be taking this to a webserver and using Applets so P2P architecture wouldn’t be applicable.

The clients will have to go through the webserver, I just want them to be able to talk to the game that has been instantiated on the webserver by the Parent Server program and the game to be able to talk to the clients directly without any of the messages from the client or the game having to go through the server program and get parsed, etc.

I am working on a client server application just to ease the developement, but I will be porting whatever I get going to the Applet.

I thought I read somewhere that you can pass the socket information from the server to the game and that would allow the game to talk to the client directly.

I’ll see if I can get that going.

Edit: I’m an idiot, I’ve been using this already for quite a while with my chat program. :o

So what I’m looking for is a way for the client to talk directly to the Game that gets launched by the Server Program instead of having to talk to the server, have the server parse the code and see what kind of message it is, who its supposed to go to, etc.

I dont know what the hell I’m talking about, between RL Work, programming 40+ hours a week, loving the family, working around the house, gettin all liquored up on the weekends, and working on the website sometimes I get a little upside down!

As long as you pass the socket info to the newly created Game thread running from the server, that game can send and receive messages to the client.

Have you come across a situation where a client might be behind a firewall/nat if port forwarding is not setup on the router for that individual client no traffic will reach the client acting as a server.
I keep my game servers seperate from the clients and limit clients to 1000 per game server(not had chance to test ).all client communication has to go through a game server because of the firewall/port/routing problem. Just a thought :O)