K20GH K20GH - 4 years ago 207
Vb.net Question

Test telnet communication on remote computer using VB.net?

I have a central server and I need to write a bit of vb.net which will see if I can telnet to a specified server on a specified port.

Is there anyway this can be done in VB.net? I thought about sending command prompts to the remote server to execute telnet, then output the logs of netsh and read those and send the information back to the central server for review.

Its a very messy way of doing it, so I was just wondering if there was an easier way

Answer Source

You should just create a TcpClient object with the IP address of the target server and port (typically 23 for telnet). Then call Connect!

See here for more info:


Something like this (may not be exact):


   Dim telnetServerIp As String = ""
   Dim telnetPort As Integer = 23
   Dim client As New TcpClient(telnetServerIp, telnetPort)
   MessageBox.Show("Server is reachable")
Catch ex As Exception 
   MessageBox.Show("Could not reach server")
End Try

Be advised this is sample code. You'd want to clean up (close/dispose) the connection (TcpClient) object when you were done, etc. But it should get you started.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download