Results 1 to 8 of 8

Thread: check if winsock is done loading?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Posts
    294

    check if winsock is done loading?

    is it possible to check when winsock is completely done loading? I want to display a msgbox saying "completed" when the WHOLE data is retrieved in the dataarrival.

    here's what i would usually do:

    ---get data from dataarrival
    ---then
    ---if instr(text1.text, "done loading") ' "done loading" is the text at the end of the page
    ---msgbox "completed"


    but it wont work this time, it's a bit hard to explain why, but is there another way of doing this?

  2. #2
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: check if winsock is done loading?

    Normally I put something at the end of the data like you suggested.

    Another way is to put the number of bytes to be transferred at the begining of the data.

    What are you using to transfer the data?

  3. #3
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: check if winsock is done loading?

    you can even use some chars as begin and end chars. like _S and _E for start and end of the string
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Posts
    294

    Re: check if winsock is done loading?

    Quote Originally Posted by moeur
    Another way is to put the number of bytes to be transferred at the begining of the data.
    do you have an example of this?


    Quote Originally Posted by moeur
    What are you using to transfer the data?
    I'm using winsock, is that what you mean?



    Quote Originally Posted by ganeshmoorthy
    you can even use some chars as begin and end chars. like _S and _E for start and end of the string
    I dont get what your saying.... Im totally confused

  5. #5
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: check if winsock is done loading?

    are you using the Winsok control?

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Posts
    294

    Re: check if winsock is done loading?

    yea im using the winsock control

  7. #7
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: check if winsock is done loading?

    Originally Posted by moeur
    Another way is to put the number of bytes to be transferred at the begining of the data.

    do you have an example of this?
    Just like you were doing with "done loading"

    To Send the data just append the length of the data
    Code:
    Sub SendData(strData As String)
        Dim strX As String
        Dim HH As Byte
        Dim MM As Byte
        Dim LL As Byte
        Dim lstring As Long
        lstring = Len(strData)
        LL = lstring And &HFF
        MM = (lstring / &H100) And &HFF
        HH = (lstring / &H10000) And &HFF
        strX = Chr(HH) & Chr(MM) & Chr(LL) & strData
        Winsock1.SendData strX
    End Sub
    When the data arrives just strip off that number
    Code:
    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    
    Static FullData As String
    Static dataCount As Long
    Dim strData As String
    
        Winsock1.GetData strData
        If dataCount = 0 Then 'get header
            'let's asumme that the most data that will come in is < 15MB
            'then 1st 3 bytes tell us how much data is coming
            'assume format HH MM LL
            dataCount = Asc(Mid(strData, 1, 1)) * &H10000 + _
                        Asc(Mid(strData, 2, 1)) * &H100 + _
                        Asc(Mid(strData, 3, 1))
            FullData = Mid(strData, 4)
            dataCount = dataCount - Len(FullData)
        Else
            FullData = FullData & strData
            dataCount = dataCount - Len(strData)
        End If
    
        If dataCount <= 0 Then
            MsgBox "Finished"
            dataCount = 0
        End If
    
    End Sub

  8. #8
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: check if winsock is done loading?

    Quote:
    Originally Posted by ganeshmoorthy
    you can even use some chars as begin and end chars. like _S and _E for start and end of the string

    I dont get what your saying.... Im totally confused
    to determine whether last bit of string is received at the end, you can check the special chars.. like if you are passing abcde then pass it like _Sabcde_E
    and check for _E to confirm you have received the full string, instead of "done loading" and all, coz "done loading" could have been used by the user also within the string, so, you terminate the string with special chars like ^ or | or something else.
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


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