[ENet-discuss] Disconnect order

Ruud van Gaal ruud at racer.nl
Fri Mar 21 06:05:34 PDT 2008


Hi,

I am seeing strange things with disconnects that seem out of order. I've
made a server and a client app which just connects to the server. Then I
startup the client 3 times, hard exiting it with Ctrl-C (I had trouble with
keeping a list of connected clients). After a couple of seconds, disconnects
get through due to timeouts ofcourse.
I saw a weird thing when administering attached clients though. This is the
output:

Server listening to UDP port 28100
QNServer: client connects from 6500a8c0:2851.
QNServer(00DB5760) has 1 clients:
#0: 192.168.0.101, id 71, peer 0x00DBA048
QNServer: client connects from 6500a8c0:2853.
QNServer(00DB5760) has 2 clients:
#0: 192.168.0.101, id 71, peer 0x00DBA048
#1: 192.168.0.101, id 72, peer 0x00DBA19C
QNServer: client connects from 6500a8c0:2855.
QNServer(00DB5760) has 3 clients:
#0: 192.168.0.101, id 71, peer 0x00DBA048
#1: 192.168.0.101, id 72, peer 0x00DBA19C
#2: 192.168.0.101, id 73, peer 0x00DBA2F0
QNServer: client 192.168.0.101 disconnects (id 72, event.peer 0x00DBA19C,
c->peer=00DBA19C, data 00000048).
QNServer(00DB5760) has 2 clients:
#0: 192.168.0.101, id 71, peer 0x00DBA048
#1: 192.168.0.101, id 73, peer 0x00DBA2F0
Disconnect from id 72
QNServer: client 192.168.0.101 disconnects (id 71, event.peer 0x00DBA048,
c->peer=00DBA048, data 00000047).
QNServer(00DB5760) has 1 clients:
#0: 192.168.0.101, id 73, peer 0x00DBA2F0
Disconnect from id 71
QNServer: client 192.168.0.101 disconnects (id 73, event.peer 0x00DBA2F0,
c->peer=00DBA2F0, data 00000049).
QNServer(00DB5760) has 0 clients:
Disconnect from id 73

(Note in the output that c-> is a Client object that I'm administering
myself. So for every connect I make a structure in my game (for example, to
store the name of the player, or such); it stores a pointer to the peer.
That's why there is event.peer and c->peer. I use ID's (starting from 71) in
the peer->data field to identify clients. I can't use a Client* since the
array of Client[]-s gets shifted on disconnects (making any peer->data
pointer point to the wrong object).)

As you can see, the 3 connects are ok. Then, the disconnects come in, but
the 2nd connection drops first. Any idea why that would be the case? I'd
expect the first peer to be dropped first. That is, after a few tries,
almost never the case (sometimes id 71 drops at about the same time). Trying
with 4 client connects I get drop order: 72-71-73-74. Like the first peer is
special (which is often a sign of a small bug somewhere).

BTW The tutorial says to set event.peer->data to 0 if a DISCONNECT occurs. I
assume this is just there for safety? (can't think of anything why this
would actually be required).

Cheers,
Ruud



More information about the ENet-discuss mailing list