Just for fun, I copied the class to a regular Console application. It works without problems.
Here's the code.
Do While (True) Array.Clear(m_aBuffer, 0, BLOCK_SIZE) m_iBytes = m_objClientSocket.Receive(m_aBuffer, m_aBuffer.Length, 0) Debug.Print("m_iBytes: " & m_iBytes) m_sMes += Encoding.UTF8.GetChars(m_aBuffer, 0, m_iBytes) Debug.Print("m_sMes in loop: " & m_sMes) If (m_iBytes < m_aBuffer.Length) Then Debug.Print("m_iBytes is less than the buffer") Exit Do End If Loop
The BLOCK_SIZE is set to 512. m_objClientSocket.Receive stops after reading 256 bytes. I tried to change the size to 128 just to test it. The loop continues until .Receive has read a TOTAL of 256 bytes.
I am lost. Any pointers?