[ENet-discuss] enet_peer_disconnect() and its data field

Marc Rochel marc.rochel at udicom.de
Sat Dec 29 17:59:18 PST 2007

Hi !

I'm not sure if this is correct behaviour or a bug: In enet.h the
disconnect event is discribed as follows:

   /** a peer has disconnected.  This event is generated on a successful

     * completion of a disconnect initiated by enet_pper_disconnect, if 
     * a peer has timed out, or if a connection request intialized by 
     * enet_host_connect has timed out.  The peer field contains the
     * which disconnected. The data field contains user supplied data 
     * describing the disconnection, or 0, if none is available.

Doing a enet_peer_disconnect with a data field != 0 like

	enet_peer_disconnect(peer, 6);

generates ENET_EVENT_TYPE_DISCONNECT on both ends of the connection. But
only the non-initiating side gets the supplied
data field value of 6. The side which initiates the disconnect always
gets a 0. I expected it to get the same value as well.

My plan was to always call the enet_peer_disconnect with a data field
value != 0 to distinguish between a dropped connection, a disconnection
initiated from the other side and a disconnection initiated locally. But
with this behaviour, the initiating side always thinks the connection
got dropped.

The latest entry in ChangeLog in my version of Enet is "ENet 1.1 (June
6, 2007)". I downloaded it on 2007-12-16 though.

Best regards

More information about the ENet-discuss mailing list