Server on MacOS is not sending ADMIN_PACKET_SERVER_WELCOME packet #8525
Version of OpenTTD
I received only
Steps to reproduce
Same code works on Windows 10 (latest revision).
The text was updated successfully, but these errors were encountered:
The code responsible for sending these packets is
and doesn't depend on the platform.
Both packets are queued and should be sent sooner or later.
Important to note, although most of the time these packets will be received in a single TCP packet, this one will not. It will most likely be a single TCP packet containing two OpenTTD packets. I know this can be a bit confusing, so let me try to explain a bit:
TCP sends packets when ever it feels like is a good moment. Depending on the OS, the rules are a bit different, but think of it like this: if the packet is (almost) full (so called MTU) or 20ms has elapsed, send out this packet. OSes do this, as it is much better for speed to send a single big packet, a bit delayed, over a lot of small packets.
OpenTTD mostly sends out packets one at the time, with a good delay between each. As such, it is pretty common that a single OpenTTD packet is in a single TCP packet. But in this case, both packets are send at nearly the same time. In result, that most likely are being put in a single TCP packet, and send to the other side.
OS difference here is huge, and I only paint you an abstract picture here (so for the nitpickers reading this: there is a lot of nuance to this story, I am well aware :D). If I would be to guess, Windows sends 2 TCP packets where MacOS sends one, and you are noticing this difference.
I would suspect that in your client you simple do: on TCP receive, read OpenTTD packet, wait for next TCP packet. But in reality you have to loop over the TCP packets, checking if there is more than one OpenTTD packet in there. In fact, it is possible that 1 OpenTTD packet can be over multiple TCP packets.
I hope I explained this well enough for you to understand, as it is not really easy to explain in text, I noticed while writing this :) And I hope I am guessing right here :P
As I don't speak C# or F#, I could not validate this in your client .. but in pseudo code:
Again, I can be completely wrong, so possibly it is good to first validate if this is happening: check after reading an OpenTTD packet if the data buffer you get from the socket was bigger than what you just handled.
Hopefully this helps you :)
For reference, this is how we do it in C++: https://github.com/OpenTTD/OpenTTD/blob/master/src/network/core/tcp.cpp#L145
Found this, might help you out:
Maybe it helps to see how others solved it, instead of my psuedo-code :)