[ENet-discuss] enet_peer_disconnect() and its data field
marc.rochel at udicom.de
Sat Dec 29 20:49:12 PST 2007
Ok, makes sense. Then I'll determine it another way.
In your example, do you get 1 or 2 ENET_EVENT_TYPE_DISCONNECT events?
Von: enet-discuss-bounces at cubik.org [mailto:enet-discuss-bounces at cubik.org] Im Auftrag von Lee Salzman
Gesendet: Samstag, 29. Dezember 2007 21:31
An: Discussion of the ENet library
Betreff: Re: [ENet-discuss] enet_peer_disconnect() and its data field
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.
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
> * 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.
> 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
ENet-discuss mailing list
ENet-discuss at cubik.org
More information about the ENet-discuss