How to check if telnet has been connected successfully?

0 votes
asked May 29, 2015 by tadeystas (120 points)

After command:

telnet1 = New Telnet("")

How to check if telnet connected successfully without submitting any commands/login.
Would like to be able to get something like:
dim telnetConnected as boolean = telnet1.IsConnected

1 Answer

0 votes
answered Jun 1, 2015 by Tomas Knopp (58,890 points)
edited Jun 1, 2015 by Tomas Knopp

The line

Telnet telnet1 = New Telnet("")

actually does not connect to the server yet. The connection will actually be made each time a new instance of Scripting or VirtualTerminal object is requested or when the Bind method of the TerminalControl or VirtualTerminal is called. Then you could suppose that you are connected to the server. However, getting the connection state without issuing any command is not possible even then. Imagine that someone would unexpectedly abort the connection (just pull out the Ethernet cable for instance) and then any connection is lost immediately and you do not have any means to find out until you try issuing some command:

' create the telnet client
Dim client As New Telnet(hostname)

' connect and get a scripting object
Dim scripting As Scripting = client.StartScripting()

' authenticate, send command and read responses
' ...

' close the telnet ssession

For more details see the Connecting to Telnet servers chapter of our web documentation.

commented Jun 1, 2015 by tadeystas (120 points)
So, how can I check after issuing "Dim scripting As Scripting = client.StartScripting()" that I am ready to login? In case there is a routing issue or anything else, I want to be able to get an error message saying that program was not able to telnet to the system.
commented Jun 2, 2015 by Pavel Matyska (15,060 points)
Hi, if you get an instance of the Scripting class, then you are connected. If the client.StartScripting() throws an exception, then the connection could not be estabilished.
commented Jun 3, 2015 by tadeystas (120 points)
edited Jun 3, 2015 by tadeystas
So when I am debugging I am getting: Rebex.Net.ProxySocketException

When I try to catch it, it tells me that Rebex.Net.ProxySocketException is not defined.

commented Jun 4, 2015 by Pavel Matyska (15,060 points)
Hi, please make sure you have references to these dlls in your project:

The Rebex.Net.ProxySocketException is defined in Rebex.Networking.dll and for future uses, there is a log writer in Rebex.Common.dll
In fact, Rebex.Telnet.dll needs all remaining three libraries to work properly, when you deploy your application to production environment.
commented Jun 4, 2015 by tadeystas (120 points)
I as missing Common and Networking.
Works like a charm now. Thank you so much!!!
commented Jun 4, 2015 by Tomas Knopp (58,890 points)
Thanks for the update. Good to hear everything is working now!