Reputation: 87
I'm coding a C# server application which receives a large byte array from an Android client via TCP. The problem is that the Android client is sending 14952 bytes, while the C# can't receive more than 4344. Any way to enable the C# TCP server to receive all the 14952 bytes?
Upvotes: 0
Views: 458
Reputation: 59623
TCP is a stream protocol. The only buffer size that you can reliably receive is a single byte. A proper TCP server will call recv
in a loop until it has read as many bytes as it needs to process the message. The application-layer protocol needs to either (1) include the byte size of the message in the message itself or (2) needs to define how messages are framed over the underlying stream of bytes.
Short Answer: the TCP layer is free to present the bytes to the application layer in whatever byte size chunks it wants provided that the bytes remain in the same order that they were sent in.
Upvotes: 3