|
-
Feb 1st, 2005, 07:12 AM
#9
Thread Starter
Lively Member
Re: How to LOOP this ?
 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:
Public Function receive() As String
Dim stringBuffer As String
Dim recvBuffers(4)() As Byte 'an array of arrays
|
recvBuffers(0) = New Byte(tcpClient.ReceiveBufferSize) {} |
recvBuffers(1) = New Byte(tcpClient.ReceiveBufferSize) {} |-----> this is the part I am concerntrate on. Which have to decide how many recvBuffers to create
recvBuffers(2) = New Byte(tcpClient.ReceiveBufferSize) {} |
recvBuffers(3) = New Byte(tcpClient.ReceiveBufferSize) {} |
recvBuffers(4) = New Byte(tcpClient.ReceiveBufferSize) {} |
For i As Integer = 0 To 4 Step 1 -------------------->number of loop also depending on how many recvBuffer created
ns.Read(recvBuffers(i), 0, CInt(tcpClient.ReceiveBufferSize))
stringBuffer = stringBuffer + Encoding.ASCII.GetString(recvBuffers(i), 0, CInt(tcpClient.ReceiveBufferSize))
Next
Return stringBuffer
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.. ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|