Quote:To make it work in all cases I just have to pass identical fixed length parameters to the BeginSend and BeginReceive calls on the respective sides and this will lead to excessive bytes being transmitted
That won't work. Even if you pass 20 to BeginSend, and 20 to BeginReceive, at the other end, BeginReceive may end up only receiving 10 bytes, and the next BeginReceive might get 5 -- or might get 50, if there is more data pending. You have to treat a TCP stream as you would a file on disk, with the additional gnarl that the "receive" operation may return less than you asked for, even when the file isn't at the end.