I have been writing a simple tcp client and server. I want to verify when to close the network stream. I have a the server thread pushing out data to the listener, but it does so as new data gets generated. Do I close the network stream when I'm done sending a particular unit of data? Or do I only close the stream when I'm totally done with the client and want to disconnect?
m_tcOutput is already a connected tcpClient.
is the above ok? Or should I remove the nsOut.Close() call? Remember that I am not done yet, and I will signal the thread to send the client some more data later.
System.Net.Sockets.NetworkStream nsOut = null;
nsOut = m_tcOutput.GetStream();
nsOut.Write(data, 0, data.Length);