Hello,

I am attempting a little LAN-matchmaking prototype using a wrapper over ENet. 
The idea is the following:

One or more players (the 'servers') create a ENet host bound to a given port, 
and accepting a given number of connections.

Other players (the 'clients') each create a host that initiate several 
broadcast connections toward that same port. What I want is for each 'server' 
to establish one valid connection for each separate 'client'. Unfortunately, 
this doesn't seem to be the case. Let's say that I have a single server 
accepting 4 connections, and a single client issuing 4 connection request, all 
4 of them will be validated by the same server.

If I understand well, there already is some rejection mechanism that looks like 
it is more suited to reject packet duplicates than multiple connection attempts 
from the same distant host:

static ENetPeer *
enet_protocol_handle_connect (ENetHost * host, ENetProtocolHeader * header, 
ENetProtocol * command)
{
...

    for (currentPeer = host -> peers;
         currentPeer < & host -> peers [host -> peerCount];
         ++ currentPeer)
    {
        if (currentPeer -> state != ENET_PEER_STATE_DISCONNECTED &&
            currentPeer -> address.host == host -> receivedAddress.host &&
            currentPeer -> address.port == host -> receivedAddress.port &&
            currentPeer -> connectID == command -> connect.connectID)
          return NULL;
    }
...

So my question is twofold:

Is it the expected behavior for a host to validate multiple connection attempts 
from a given distant host?
What is the best way to change this behavior to ensure only one connection is 
ever active between two hosts? Removing the currentPeer -> connectID == command 
-> connect.connectID part of the test seems to do the trick, but what are the 
risks of doing this?


Benoit.
_______________________________________________
ENet-discuss mailing list
[email protected]
http://lists.cubik.org/mailman/listinfo/enet-discuss

Reply via email to