Quote Originally Posted by taxes
Hi,

Are you saying that you don't know how to get data from a file?
No, I don't know how to receive the data until the last data comes in. In short, don't know how to receive fully from server before it return.

I got my code simplified.

VB Code:
  1. Public Function receive() As String
  2.         Dim stringBuffer As String
  3.         Dim recvBuffers(4)() As Byte 'an array of arrays              
  4.                                                                                                  |
  5.         recvBuffers(0) = New Byte(tcpClient.ReceiveBufferSize) {}           |
  6.         recvBuffers(1) = New Byte(tcpClient.ReceiveBufferSize) {}           |-----> this is the part I am concerntrate on. Which have to decide how many recvBuffers to create
  7.         recvBuffers(2) = New Byte(tcpClient.ReceiveBufferSize) {}           |
  8.         recvBuffers(3) = New Byte(tcpClient.ReceiveBufferSize) {}           |
  9.         recvBuffers(4) = New Byte(tcpClient.ReceiveBufferSize) {}           |
  10.                                                                                        
  11.         For i As Integer = 0 To 4 Step 1 -------------------->number of loop also depending on how many recvBuffer created                                    
  12.             ns.Read(recvBuffers(i), 0, CInt(tcpClient.ReceiveBufferSize))
  13.             stringBuffer = stringBuffer + Encoding.ASCII.GetString(recvBuffers(i), 0, CInt(tcpClient.ReceiveBufferSize))
  14.  
  15.         Next
  16.         Return stringBuffer
  17.     End Function

In case you don't aware, the number of recvBuffer is base on data comes in. If still have data, create another recvbuffer. if no, then exit the loop.
thanks wossname for the code above. Texas...can you fugure out.. ?