I\'m sending a large amount of data in one go between a client and server written C#. It works fine when I run the client and server on my local machine but when I put the
Well there's one thing wrong with your code to start with, if you're counting the number of calls to Receive
which complete: you appear to be assuming that you'll see as many Receive
calls finish as you made Send
calls.
TCP is a stream-based protocol - you shouldn't be worrying about individual packets or reads; you should be concerned with reading the data, expecting that sometimes you won't get a whole message in one packet and sometimes you may get more than one message in a single read. (One read may not correspond to one packet, too.)
You should either prefix each method with its length before sending, or have a delimited between messages.