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

Lee Salzman lsalzman1 at cox.net
Sat Dec 29 12:31:25 PST 2007


The reason it is always 0 on the initiating end is that the
data field is meant to represent a very small message sent
to the other end along with the disconnect. If it was any
value other than 0, you would have the same problem really:
you'd have no way of knowing whether the disconnect you
got was because the remote end disconnected between
when you issued your disconnect request and when you
got the event.

Lee

Marc Rochel wrote:
> 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
> peer 
>      * which disconnected. The data field contains user supplied data 
>      * describing the disconnection, or 0, if none is available.
>      */
>    ENET_EVENT_TYPE_DISCONNECT = 2,   
>
> 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
>     Marc 
>   



More information about the ENet-discuss mailing list