0

I'm writing a simple binary protocol over TCP/IP: It is composed as below

[DATASIZE - 2 Byte Fixed][DATA]

With this solution, even I read multiple messages, I can divide each one by its size, but I have one doubt: It is possible to receive only a "portion" of a single message?

1 Answer 1

2

The only messages that you can receive over a TCP streaming service are single bytes. Anything more complex may be received in single bytes or any multiples. So, yes, you can receive 'only a "portion" of a single message' in a single receive call.

Sign up to request clarification or add additional context in comments.

2 Comments

When an host send a 10 bytes message maybe I can receive it separated ( like the first 3 byte followed by the last 7 byte ) but it is possibile that TCP lost the first 3 byte and receive only the last 7? ( Maybe in strange situation like cable disturbed or wifi connection )
'it is possibile that TCP lost the first 3 byte and receive only the last 7?' No, not in a well-behaved implementation. The last 7 would not be delivered to the app layer because of the failed delivery of the earlier 3 bytes - the sequence numbers would be out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.