Back to product page
- Introduction
- License agreement
- Getting Started
- Enumerations
- Objects
- wodTelnetDLX
- Methods
- Properties
- Authentication
- AutoSize
- BackColor
- BackLog
- BindIP
- BindPort
- Blocking
- BorderVisible
- Certificate
- CharEncoding
- Column
- Columns
- ColWidth
- Command
- ContextMenu
- CursorHeight
- DataOut
- DataReady
- Enabled
- ErrorText
- ExitSignal
- ExitStatus
- Font
- ForeColor
- HandleSysKeys
- Hostname
- hWnd
- KeepAlives
- Language
- LastError
- LocalCertBag
- Login
- MousePointer
- MouseWheel
- MyHostname
- MyIP
- Notification
- Password
- Picture
- Port
- Prompt
- Protocol
- ProxyHostname
- ProxyLogin
- ProxyPassword
- ProxyPort
- ProxyType
- RecordMode
- RemoteIdentification
- Row
- RowHeight
- Rows
- ScrollBars
- ScrollX
- ScrollY
- SecureMethod
- SelectedText
- ShowCursor
- Socket
- SpecialKeyFocus
- State
- StateText
- StripANSI
- StripColors
- TabStop
- TelnetOption
- TerminalEmulation
- TerminalType
- Text
- Timeout
- TranslateSpecial
- UseIPv6
- Version
- Events
- IwodTelnetNotify
- wodTelnetDLX
- How to get support?
- Technical information
- Fast notifications interface
- Error list
WaitFor method
Waits and reads data until pattern is found.
Type
StringRemarks
This method is only available in COM version of the component.WaitFor method will wait and receive data from the server, until specified Pattern is found, or timeout expires. If timeout is not specified, then default one is used, as defined in Timeout property. If timeout expires, you will get an error, but you will still be able to receive data that arrived in the meantime using Receive method call.
NOTE: this method works only when Blocking property is set to True.
Very common way for using WaitFor method is to read all data that servers sends us upon connection. Usually you will know what exactly you need to receive, so you can use this command to help you, like this:
TelnetDLX1.HostName = "yourhost"
TelnetDLX1.Login = "tester"
TelnetDLX1.Password = "weonlydo"
TelnetDLX1.Protocol = SSHAuto
TelnetDLX1.Blocking = True
TelnetDLX1.Connect
Debug.Print TelnetDLX.WaitFor("joe@debian")
This sample will block until joe@debian is found within received text. If it's not found in reasonable time (until timeout expires) you will still be able to Receive last 16k of data - just to check why it failed.
Timeout can be specified as negative value too. When set up this way, wodTelnetDLX will use it as 'absolute timeout' - component will return from WaitFor method call in specified time no matter if it was idle or busy in that time. It is so to prevent wodTelnetDLX from freezing if expected response is never received. wodTelnetDLX.Timeout property will still hold regular, 'inactivity timeout' value as it was before.
One sidenote - it is almost impossible to predict what state of the session will be when this 'absolute timeout' expires. You may still receive big amount of data that will confuse your client, depending on what was going on while WaitFor method was running.
This command internally disables PromptReceived event and Received event since it's taking control on what's received from the server.
You can also provide regular expression to be searched in received data instead of exact value. You should prepend your Waitfor argument with regex: text so wodTelnetDLX knows you are using regular expression. For example, you can use it like this:
Debug.Print Telnet1.WaitFor("regex:[\$%#>] $")
above regular expression will match when:
- $, %, #, or > found
- space
- end of line
Debug.Print Telnet1.WaitFor("regex:[a-zA-z0-9]+@[a-zA-z0-9]+:[a-zA-z0-9-/]+[\$%#>] $")
or using extended PERL syntax
Debug.Print Telnet1.WaitFor("regex:\w+@\w+:\S+\$ $")
just don't forget to put regex: text in front of regular expression, otherwise wodTelnetDLX will search for exact match of specified pattern. PCRE (www.pcre.org) library is used for regex support.