-
Notifications
You must be signed in to change notification settings - Fork 671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
data (4th) argument of enet_host_connect() is not set in the CONNECT event received on the CLIENT side. #198
Comments
I suppose that I should have stated what I expected. I expect that 32-bit unsigned integer value of the 4th argument to |
Update: The data value is present on the SERVER (receiving) side in the CONNECT event ENetEvent::data member. However, it is always ZERO on the CLIENT (sending) side CONNECT event. Technically, this does match the documentation. However, I suggest (maybe I'll send a PR) that the value be present in the CLIENT CONNECT event also. My own code uses one common "while() / switch (event.type)" block, so server vs client distinction is thin at best. Repro: https://gist.github.com/dennisjenkins75/2d8e1cc5591a877583336ddfa62fa758
|
@dennisjenkins75 I can confirm the behavior, the |
So, I'd like to convert this "issue" from a "bug report" to a "feature request" and ask that the |
@dennisjenkins75 I have looked into the code, and it should be fairly trivial. Right now it only copies the I would add it here: Line 212 in 3340d1c
Then when the This is (if I understand it right) done here Line 130 in 3340d1c
Note, I have not verified this hypothesis, but it should be trivial to test. |
The sending end leaves eventData at 0 so that you can distinguish whether you are initiating the connection or whether you are receiving the connection. This is intentional behavior. If you want something on the sending side, then use peer->data. |
@lsalzman Right, that's a good point, I have worked around that limitation in a similar way but I remember being confused during my early days the same way as @dennisjenkins75. Perhaps this may need a bit of clarification in |
Will modifying the |
(Updated after stand-alone repro showed the the SERVER side sees the value, but the CLIENT side does not.)
The docs for
enet_host_connect()
state that the final argument,enet_uint32 data
is "user data supplied to the receiving host". Sadly when the sending (client) host receives theENET_EVENT_TYPE_CONNECT
event, that data value is NOT set in theENetEvent->data
member; the value is always zero. In fact, none of the data members reachable from the event (such asevent->peer->data
orevent->peer->eventData
) have the magic 32-bit value that I specified in my call to enet_host_connect().My intent was to use this value on the server side to allow the server to reject a client that did not specify the expected 32-bit value. However, my own project uses common code (both the client and server end) to run the ENet "while / switch" event pump.
Confirmed w/ GDB:
Application logs:
I can confirm w/ wireshark that my uint32 is present in the UDP packet going from the client to the server. The last 4 bytes of the outbound packet (wireshark capture is from a different run of the same test, so the UDP port numbers are different, as is the connectionID; but its all the same code):
The text was updated successfully, but these errors were encountered: