You need one socket for each client + one for accept/listening.
So when a new client joins you create a new socket. The questions however is, how do I tell everyone this new client joined, in a peer to peer enviroment. Should the new client connect to another client, this "already connected client" sends back a reply with the ip and ports of all other clients and then I connect to each of them, one by one? (Sounds Very Slow)
Another way would be for the Client who first get contact with the "new client" to send this data to all clients already connected; he already know them peer to peer. These can now in turn connect to the new client. However I assume that would mean that each of these clients would freeze for a small moment evertime someone connects, which would be unacceptable.
Are there a simpler way to create connections with TCP? It seems to me that if a player connects to a 64player game, he must wait a very long time for TCPConnect on each and every client, just so that we have the direct peer to peer option.
Any ideas or links?
|