You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The socket communication is missing proper handling of partial transfers and requires message framing.
The current code only works as long as one call to Boost.Asios async_receive() returns exactly one message, but this is not guaranteed. As a consequence messages are lost or the app crashes when it attempts to deserialize incompletely transferred Flatbuffer objects.
The amount of bytes read from a TCP socket by a single call to recv() (and so Boost.Asios async_receive()) is not guaranteed to match the amount of bytes, which have been sent from the other side with one send() call. Only part of the data from one call or data from multiple send() calls could be returned.
Additionally send() and recv() may transfer less than the requested number of bytes. The number of actually transferred bytes should always be checked and partial transfers resumed by another call to transfer the remaining data.
To ensure that only complete messages are deserialized, message framing should be added. For instance by prepending each message with its size in bytes and then using async_read() instead of async_receive() to read this exact number of bytes.
The text was updated successfully, but these errors were encountered:
The socket communication is missing proper handling of partial transfers and requires message framing.
The current code only works as long as one call to Boost.Asios async_receive() returns exactly one message, but this is not guaranteed. As a consequence messages are lost or the app crashes when it attempts to deserialize incompletely transferred Flatbuffer objects.
The amount of bytes read from a TCP socket by a single call to recv() (and so Boost.Asios async_receive()) is not guaranteed to match the amount of bytes, which have been sent from the other side with one send() call. Only part of the data from one call or data from multiple send() calls could be returned.
Additionally send() and recv() may transfer less than the requested number of bytes. The number of actually transferred bytes should always be checked and partial transfers resumed by another call to transfer the remaining data.
To ensure that only complete messages are deserialized, message framing should be added. For instance by prepending each message with its size in bytes and then using async_read() instead of async_receive() to read this exact number of bytes.
The text was updated successfully, but these errors were encountered: