Closing/disposing the NetworkStream should not be necessary, but I would question the manner in which the data is being sent. Did you write the server? I would expect either a length prefix on the data being sent (and received) or a termination character or phrase.
If you just write the data like that, the server can't know how much of the data it should read.
Closing/disposing the NetworkStream should not be necessary, but I would question the manner in which the data is being sent. Did you write the server? I would expect either a length prefix on the data being sent (and received) or a termination character or phrase.
If you just write the data like that, the server can't know how much of the data it should read. The same goes for the receiving code. You're simply trying to read up to the ReceiveBufferSize rather than using a length being sent to you by the server.
Are you certain that the protocol you're using doesn't include these elements? Also, bear in mind that Read as with most/all other Stream objects, does not guarantee that you'll get the number of bytes you request. It will read up to that number of bytes and the return value of the function indicates how many were read.
You typically have to set up a loop structure to get a specific number. Something like... int bytesToRead = 1024; // sample int totalBytesRead = 0; int bytesRead = 0 while(bytesToRead > 0) { bytesRead = stream. Read(buffer, totalBytesRead, bytesToRead); if(bytesRead == 0) throw new Exception("Connection closed"); totalBytesRead += bytesRead; bytesToRead -= bytesRead; } This is somewhat more verbose than a typical implementation to give you an idea of what needs to be happening.
Something more typical would be: int bytesToRead = 1024; int bytesRead = 0; while((bytesRead += stream. Read(buffer, bytesRead, bytesToRead - bytesRead).
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.