[ENet-discuss] Differentiating multiple peer clients from sameremote machines

Ruud van Gaal ruud at racer.nl
Tue May 19 02:19:06 PDT 2009


> -----Oorspronkelijk bericht-----
> Van: enet-discuss-bounces at cubik.org 
> [mailto:enet-discuss-bounces at cubik.org] Namens David Lethe
> Verzonden: Tuesday, May 19, 2009 07:45
> Aan: enet-discuss at cubik.org
> Onderwerp: [ENet-discuss] Differentiating multiple peer 
> clients from sameremote machines
> 
...

> So, how do I properly identify the individual peers running 
> on the remote systems when I get an ENET_EVENT_TYPE_CONNECT, 
> and use the The host is bound to ENET_HOST_ANY, at UDP port #4079.  

I use the following to uniquely identify client ID's in my QNClient
abstraction class:

    if(event.type==ENET_EVENT_TYPE_CONNECT)
    {
      if(peer)
      {
        // Already connected
        qinfo("QNClient: connect event but peer already connected, so drop
this one");
        enet_peer_disconnect(event.peer,0);
        enet_host_flush(host);
      } else
      {
        // No one connected yet; accept this one
        SetConnected(true);
        peer=event.peer;
        // Get a client ID from ENet internals - note the server is always
BASE_ID, so start one beyond that
        id=event.peer->outgoingPeerID;
        qinfo("QNClient: connected to server (our clientID=%d)",id);
      }

Hope that helps,
Ruud



More information about the ENet-discuss mailing list