-
DataArrival
Hello; I hope some-one can help me.
I am coding a program that uses Winsock to retrieve the data of a Server.
Code:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim YuBytes As Long
Winsock1.GetData YUBytes
firstbyte = Hex(AscB(YUBytes)) 'convert it to Hex
sClMessage = "Received data " & firstbyte & " from " & Winsock1.RemoteHostIP
List1.AddItem (sClMessage)
Select Case firstbyte
Case "35"
Winsock1.SendData chr(0) & chr(0) & chr(0)
Case "34"
Here is where the problem comes in the server sends me 3 separate pockets with the same firstbyte as "34", the information I need to retrieve is not on the first packet but on the second one, Y want to retrieve a character that comes on the "middle" packet not on the first-one.
it had to be something like:
Case "34"
don't get the first packet only the second one. And look for the character on a specific area, and retrieve that character. But i don't know how to do it. I tried and tried but when I use the
Mid() function It searches the first packet only.
Please help
-
You could have a global boolean firstPacketIn...so you could do something like this:
Code:
...
Case 34:
If firstPacketIn Then
' Deal with the second packet
Else
firstPacketIn = True ' This must be the first packet, so flag for the second
End If
...
Hope this helps!