I am trying to send image via TcpClient and BufferedStream. The problem is that i cant send the data without disconnecting the TcpClient.
Send data:
while ((bytesread = bufferedinput.Read(buffer, 0, sizeBuffer)) > 0)
{
//Sending data
bufferedoutput.Write(buffer, 0, bytesread);
}
Receive data:
while ((bytesread = bufferedinput.Read(buffer, 0, buffsize)) > 0)
{
bufferedoutput.Write(buffer, 0, bytesread);
}
where :
NetworkStream serverStream = client.GetStream();
and BufferedStream bufferedoutput = new BufferedStream(serverStream);
The problem is that i must cast bufferedoutput.Close();
in the client side to get the data received by the server, but this disconnects my client, which is a problem. Any suggestions?