Winsock Data Arrival Event-VBForums
Results 1 to 4 of 4

Thread: Winsock Data Arrival Event

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2012
    Location
    Indonesia
    Posts
    5

    Question Winsock Data Arrival Event

    Hello everybody,

    I have an application using mswinsock control that connect to telnet port, and I'm making a function to print the output from host, to text file.
    When the response from host is more than one page, I have to send some input entry to make it scroll down one page, then write the next page to the file, and so on.

    The question is, is it possible to resume to my Subroutine, when the Data Arrival Event triggered, but not at Winsock1_DataArrival() Sub?

    Code Example:
    Code:
    Private Sub PrintOutputtoFile()
        Dialog1.ShowOpen
        Open Dialog1.FileName For Output As #TmpInt
        Print #TmpInt, textOut.Text
        If Instr(textOut.text,1,vbnewline & ")") then      'Scroll Indicator Exist
             Winsock1.SendData "md"                           'Send Move Down Command
    
             'The Data Arrival Event Resume Here if Possible
    
        Else
             Close #TmpInt
        End If
    End Sub
    Is there any code to make it possible? Or any other method similar to that?

    Any help is appreciated.
    Thanks.

  2. #2
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Winsock Data Arrival Event

    Not really.

    You're better off processing the whole thing in the DataArrival event.

    Not sure of your InStr statement
    Code:
    If Instr(textOut.text, 1, vbNewLine & ")") then
    did you mean
    Code:
    If Instr(1, textOut.text, vbNewLine & ")") then
    i.e. you're looking for a vbNewLine followed by a ")" to indicate that there's more data ?
    How do you know when everything has been sent ? (e.g. does it just end with a vbNewLine without the ")" ?)

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2012
    Location
    Indonesia
    Posts
    5

    Re: Winsock Data Arrival Event

    Oops, you're right. It should be:
    Code:
    If Instr(1, textOut.text, vbNewLine & ")") then
    Yap, vbnewline followed by ")" indicates that there is more data in the next page, and if there is no more data, I only got the data without vbnewline + ")", that's why I wanna make it loop until no more vbnewline + ")" at the end of data.

    Hm, just a wild guess, is there any code to save the next instruction address so it's possible to jump to that address when the DataArrival Event triggered.
    Example:
    Code:
    Private Sub con_DataArrival(ByVal bytesTotal As Long)
    Dim reply_out as String
    If con.State = sckConnected Then
        
        con.GetData reply_out
    
        If con.Tag = "PrintOutput" then        'Print Output Event Indicator
        'That code put here, if possible, to jump to that address
        End If
    End If
    End Sub
    Thanks

  4. #4
    Loquacious User Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    24,055

    Re: Winsock Data Arrival Event

    That looks like .NET, but may not be. If it is, how about passing in a delegate. If you haven't done that, it would mean passing in the address of a method. You would then call that method when the condition occurs.
    My usual boring signature: Nothing

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.