Results 1 to 4 of 4

Thread: Using Winsock In a Class (Help Please)

  1. #1

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610

    Question

    I am trying to use the Winsock Control in a class object.

    My problem is trying to figure out the best way of detecting a response from the computer I am connecting to.

    When I had a form using Winsock I waited on the DataArrival event.
    Code:
    Private Sub mobjWinsock_DataArrival(ByVal bytesTotal As Long)
    
        'Check for response from the remote host
        mobjWinsock.GetData mvarResponse
    
    End Sub
    Now that I am inside a class I can't place
    Code:
    Set mobjWinsock = New MSWinsockLib.Winsock
    in the general section of the class so that the same object can be used throughout the class and then I would be able to watch for that event.

    Sooooo....

    I could place
    Code:
    mobjWinsock.GetData mvarResponse
    in the same sub that I create the winsock control, but this needs me to another question.

    If a computer takes say 30 seconds to respond back how to I wait for the response then? Just place
    Code:
    mobjWinsock.GetData mvarResponse
    in a loop and say after 30 seconds or so in the loop error out if there is no response back? I don't know if I should keep issuing the GetData and what adverse affects it would cause.


    Thanks for any help you can give.

    [Edited by steve65 on 08-23-2000 at 09:39 AM]
    This space for rent...

  2. #2
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Uhm,
    you may want to use:
    winsock1.getdata myvar, vbstring

    Word to your mother,

  3. #3

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610
    I understand what command to use to get the response back. I am just not sure of the best way getting a response inside a class if the responding server is slow to answer.

    Originally posted by DiGiTaIErRoR
    Word to your mother,
    Huh??
    This space for rent...

  4. #4

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610
    I was able to work this out. I did not now about the Class_Initialize sub.
    Code:
    Private Sub Class_Initialize()
    
        Set mobjWinsock = New MSWinsockLib.Winsock
    
    End Sub
    Everything works great now.
    This space for rent...

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