11/20/2024, 18:16
|
#16
|
elite*gold: 0
Join Date: Sep 2022
Posts: 10
Received Thanks: 1
|
Quote:
Originally Posted by Spirited
You shouldn't hit any limit under normal circumstances going server -> client. The client has a capped length for its send buffer, though. I think it's around 1024 bytes (or something pretty small). So sometimes, you'll get a fragment of a message rather than the full message. Your socket system needs to read the length of the message from offset zero, check the length of the read from the socket, and make sure it's got the full message. Else, it needs to read more from the socket.
If you'd like an example, then Comet has a socket system that handles this already. It first decrypts the bytes, and then it splits the buffer up into multiple complete messages (leaving incomplete messages in the buffer for the next read):
This gets more complicated if you have to handle the DH key exchange in patches 5018+, because that sometimes gets cut off as well. You also have to consider the length of the 8-byte footer in the message when calculating the expected length. Comet has an example of handling that, too:

|
Thanks so much.
|
|
|