Results 1 to 2 of 2

Thread: DataArrival

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    59

    Cool 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

  2. #2
    Addicted Member csammis's Avatar
    Join Date
    Mar 2001
    Location
    /dev/null
    Posts
    226
    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!
    Things I've Said:
    "Life's funny like that...elephants can wear frilly lace panties, and Dubya still looks like a monkey in a big chair"
    "Take four goats and strap one to each foot of a llama. Presto, goat-powered llama!"
    "You want to get me to work more, get me a Coke. No? Then deal with inferior garbage, I'm not coding another line and your clients can go to......thanks, I'd love a Coke right about now!"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width