I have a C# client/server network program I've written using TCPListener and TCPClient classes. The server is reading everything from the client (small amounts of xml) just fine until I try to send a large file (100k) back to the client.
I'm using stream functions for both client and server with non-blocking socket functions. When I do a socket.SendFile("filename") back to the client, the file is getting cut off - I've set the receive buffer size on the client to well past 100k but it still gets cut off around 25k and the communication between client and server is unreliable afterwords.
My basic question is what happens if data is somehow left in the pipe ? i.e.. will it be read by the next socket.Read... Does every Send call require exactly one and only one Read ? Maybe I'm not giving the client enough time to read the file but their both on the same machine and I've tried sleeping for a few seconds in various places w/o success.
It is very possible that you cannot read the entire message through one Read call (perhaps all data has not arrived yet). In network programming, you would often place the call to Read in a while loop and simply Read() until you have received the entire expected message.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With