seilgu
seilgu

Reputation: 384

writing a server that manages many clients

I'm new to designing a server software. I'd like to have the server decide which group the client belongs to, then give the client to the appropriate program to handle. For example, people connect to battle.net first, but then the server matches the players and then they start separate games.

But I see no way of doing this. When a socket connection is established, there are no ways I can give that socket object to another program. So the only way I can think of is to invoke another server and tell the client to reconnect to that one. Is that how it's usually done? Or is there some way I don't know of that can somehow transfer ownership of a socket to another program?

Upvotes: 0

Views: 41

Answers (1)

Khushal Dave
Khushal Dave

Reputation: 507

You can do it this way.

  1. Once client connects to the server. Client needs to send some request data which contains mapping information.

  2. Server will parse this data and fork a new thread and call required function accordingly.

  3. The server thread will return and the forked child will continue.

  4. The function will handle this client and your main server can still listen to other clients request.

Hope it helps.

Upvotes: 1

Related Questions