Results 1 to 4 of 4

Thread: [RESOLVED] winsock, data receive

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2004
    Location
    cali
    Posts
    243

    Resolved [RESOLVED] winsock, data receive

    When I try to get data I get them in parts, i receive one part, another, and so on, so to get the source of the page i have to do like...

    VB Code:
    1. Winsock1.GetData Data2, vbString
    2.  
    3. Data = Data & Data2

    Only... how do i figure out when to put Winsock1.Close?
    When I add it after "Data = Data & Data2," I just get the first part/section of the html..

    I can't do (below) because not all sites have it, and are maybe just a list of something uploaded onto a webserver..

    VB Code:
    1. If instr(data, "</html>") > 0 then winsock1.close




    all of it...

    VB Code:
    1. Private Sub Command1_Click()
    2. Winsock1.Close
    3. Winsock1.Connect "profiles.yahoo.com", 80
    4. End Sub
    5.  
    6. Private Sub winsock1_connect()
    7. Winsock1.SendData "GET /auser HTTP/1.0" & vbCrLf & vbCrLf
    8. End Sub
    9.  
    10. Private Sub winsock1_dataarrival(ByVal bytesTotal As Long)
    11. Dim pdat As String
    12.  
    13. Winsock1.GetData pdat, vbString
    14. RichTextBox1 = RichTextBox1.Text & pdat
    15. End Sub


    ......

  2. #2
    Frenzied Member Spajeoly's Avatar
    Join Date
    Mar 2003
    Location
    Utah
    Posts
    1,068

    Re: winsock, data receive

    Actually, the remote server should close the connection once the data is done being sent. Drop in some code for the Winsock_Close sub.
    VB Code:
    1. Winsock1_Close()
    2.    Msgbox "Finished"
    3.       Winsock1.Close 'Just in case, you know?
    4. End Sub

  3. #3
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: winsock, data receive

    yes you should put the .close method before the msgbox because it has a tendency to loop the msgbox otherwise. The close event would be where you would know all of the page has been received, so you can process the html
    Chris

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jul 2004
    Location
    cali
    Posts
    243

    Re: winsock, data receive

    thanks
    ......

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