Hi, I'm dealing with TcpClient.ReceiveBufferSize, I really don't have a clue about how to work this out!. I have this trouble since 2 days ago, and I'm starting to believe that I'm not using it in a good way. I use it to stablish in a precisely way the length of my byte array, wich I use to receive data from socket. This is what happens: first, the server sends the client an object, I define my byte array with TcpClient.ReceiveBufferSize (it works fine). Then, server sends another object, but TcpClient.ReceiveBufferSize returns the same length of the object wich client received at first, and of course, that blows my application off, because of first object's sent length is bigger than array's length wich is receiving that object. This is what I do:

Dim BufferRead() As Byte

While Socket.Connected

BufferRead = New Byte(TcpClient.ReceiveBufferSize){}

Socket.Receive(BufferRead, BufferRead.Length, SocketFlags.None)

'more code here

End While


What's wrong with that? what structure should have my code to get a correct usage of TcpClient.ReceiveBufferSize?

Thanks for all the help I got from this forum.

Regards.