| Dart Home | PowerTCP Telnet for .NET | Custom Development | Reply | PowerTCP Telnet for .NET Topics | Forums |
| Author | Forum: PowerTCP Telnet for .NET Topic: Correct sintax for telnet1.send and Telnet1.WaitFor |
| xplorer2k From: Oxnard, CA USA Posts: 33 Member Since: 03/27/09 |
posted April 16, 2009 12:03 AM Hi, Could you please advise the correct sintax for Telnet1.send and Telnet1.WaitFor on Dart 4.0? When I used this format it gives an error: "not a member of dart.telnet.telnet. Thanks, xplorer2k |
| Jason Farrar (Admin) From: Oneida, NY USA Posts: 223 Member Since: 07/24/07 Extra Support Options Custom Application Development |
posted April 16, 2009 12:49 PM Example: Dart.Telnet.Telnet Telnet1 = new Dart.Telnet.Telnet; Telnet1.WaitFor("hello"); Telnet1.Send("Hi"); Can you give me the code you are using that is causing the exception? |
| xplorer2k From: Oxnard, CA USA Posts: 33 Member Since: 03/27/09 |
posted April 16, 2009 1:46 PM Hi Jason, Here is the code: Public Class Form1 Public APP_NAME As String = "Telnet for .NET Client Sample" Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.Text = APP_NAME & " [Connecting ...]" textDisplay.Clear() Telnet1.ClientOptions.Add(New [Option](OptionCode.SuppressGoAheads, Nothing, OptionState.RequestOn)) Telnet1.ClientOptions.Add(New [Option](OptionCode.WindowSize, New System.Byte() {(CByte(0)), (CByte(80)), (CByte(0)), (CByte(24))}, OptionState.RequestOn)) Telnet1.ClientOptions.Add(New [Option](OptionCode.TerminalType, New System.Byte() {(CByte(0)), (CByte(116)), (CByte(116)), (CByte(121))}, OptionState.RequestOn)) Telnet1.ServerOptions.Add(New [Option](OptionCode.SuppressGoAheads, Nothing, OptionState.RequestOn)) Telnet1.ServerOptions.Add(New [Option](OptionCode.Echo, Nothing, OptionState.RequestOn)) Telnet1.ServerOptions.Add(New [Option](OptionCode.OutputPageSize, Nothing, OptionState.RequestOn)) 'Connect and receive data on a separate thread 'Telnet1.Start(AddressOf connectAndListen, frm.ConnectionInfo) 'Perform appropriate login type, based on connection settings Try 'Connect to the server Telnet1.SocketOption.ReceiveTimeout = 10000 Telnet1.ServerPort = txtPort.Text Telnet1.Connect(txtIP_Address.Text) DisplayData(Telnet1.WaitFor(":")) Telnet1.Send(txtUsername.Text + Chr(10)) Catch ex As Exception Telnet1.Marshal(ex) End Try End Sub Private Sub DisplayData(ByVal s As String) 'Convert any \n\r to \r\n s = s.Replace(Chr(13) + Chr(10), vbCrLf) 'Convert all naked \n to \r\n (2-step process) s = s.Replace(vbCrLf, Chr(10)) s = s.Replace(Chr(10), vbCrLf) 'Replace all Tabs with spaces s = s.Replace(Chr(9), " ") 'Remove <esc>[0m (all attributes off) s = s.Replace(Chr(27) + "[0m", "") 'Remove <esc>[m (all attributes off) s = s.Replace(Chr(27) + "[m", "") textDisplay.AppendText(s) End Sub End Class Thanks, xplorer2k |
| Jason Farrar (Admin) From: Oneida, NY USA Posts: 223 Member Since: 07/24/07 Extra Support Options Custom Application Development |
posted April 17, 2009 10:45 AM I apologize for the delay in responding. The WaitFor and Write methods are not part of Telnet 4.0 and have been replaced with the Read and Write methods. You should replace this: DisplayData(Telnet1.WaitFor(":")) Telnet1.Send(txtUsername.Text + Chr(10)) with this: DisplayData(Telnet1.Read(":").ToString()) Telnet1.Write(txtUsername.Text + Chr(10)) |
| xplorer2k From: Oxnard, CA USA Posts: 33 Member Since: 03/27/09 |
posted April 17, 2009 11:08 AM Thanks Jason, Is it required to use the following code everytime that I need to start a new telnet session? Telnet1.ClientOptions.Add(New [Option](OptionCode.SuppressGoAheads, Nothing, OptionState.RequestOn)) Telnet1.ClientOptions.Add(New [Option](OptionCode.WindowSize, New System.Byte() {(CByte(0)), (CByte(80)), (CByte(0)), (CByte(24))}, OptionState.RequestOn)) Telnet1.ClientOptions.Add(New [Option](OptionCode.TerminalType, New System.Byte() {(CByte(0)), (CByte(116)), (CByte(116)), (CByte(121))}, OptionState.RequestOn)) Telnet1.ServerOptions.Add(New [Option](OptionCode.SuppressGoAheads, Nothing, OptionState.RequestOn)) Telnet1.ServerOptions.Add(New [Option](OptionCode.Echo, Nothing, OptionState.RequestOn)) Telnet1.ServerOptions.Add(New [Option](OptionCode.OutputPageSize, Nothing, OptionState.RequestOn)) Thanks again, xplorer2k |
| Jason Farrar (Admin) From: Oneida, NY USA Posts: 223 Member Since: 07/24/07 Extra Support Options Custom Application Development |
posted April 20, 2009 8:44 AM No it isn't required to use that code. What that code does is setup the initial parameters of the Telnet session. You should be able to just create an instance of the control and use it if you want to. |
| xplorer2k From: Oxnard, CA USA Posts: 33 Member Since: 03/27/09 |
posted April 20, 2009 6:01 PM Thanks Jason, xplorer2k |
| Reply | PowerTCP Telnet for .NET Topics | Forums |
This site is powered by
PowerTCP WebServer for ActiveX
|