-
Feb 5th, 2013, 02:04 AM
#1
Thread Starter
New Member
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.
-
Feb 5th, 2013, 06:04 AM
#2
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 ")" ?)
-
Feb 5th, 2013, 11:51 PM
#3
Thread Starter
New Member
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
-
Feb 28th, 2013, 05:43 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|