In your message, you determine how many bytes your message should contain. For example, in your case it is 1000. Below is the C # code and running it to achieve the same. The method returns 1000 bytes. Interrupt code - 0 bytes; You can tailor it according to your needs.
Application:
strMsg = ReadData(thisTcpClient.Client, 1000, out bDisconnected);
The following is the method:
string ReadData(Socket sckClient, int nBytesToRead, out bool bShouldDisconnect) { bShouldDisconnect = false; byte[] byteBuffer = new byte[nBytesToRead]; Array.Clear(byteBuffer, 0, byteBuffer.Length); int nDataRead = 0; int nStartIndex = 0; while (nDataRead < nBytesToRead) { int nBytesRead = sckClient.Receive(byteBuffer, nStartIndex, nBytesToRead - nStartIndex, SocketFlags.None); if (0 == nBytesRead) { bShouldDisconnect = true;
Let us know that this did not help you (0: Good luck.
KMån
source share