Running Telnet through VB

lilgirl

Newcomer
Joined
Jun 21, 2003
Messages
24
Hi,

Is there a particular vb.net class that would allow me to run a program using telnet to log into the particular server i want to access without making the user deal with telnet? Basically, I want a button on a vb form that when clicked, runs a program that is stored on a server you can access through telnet.

Thanks.
 
If you want to connect to a remote telnet server you should have a look under System.Net.Sockets.
The TCPClient class will allow you to open a connection to the telnet server and obtain a stream. You can then send / receive data quite easily.
What language would you be coding in?
 
Im trying somthing similiar I think.

See if this is any help

This will connect to a machine and read the inital text sent back, and store it in a log file

Imports System.Net.Sockets
Imports System.Net
Imports System.Text


Module Module1

Sub Main()
Dim tcpClient1 As New TcpClient()
Dim NS As NetworkStream
Dim bytes(tcpClient1.ReceiveBufferSize) As Byte
Dim hostaddr1 As IPAddress = IPAddress.Parse("127.0.0.1")
Dim MyEndPoint1 As New IPEndPoint(hostaddr1, 23)
Dim buffsize As Integer
Dim buff2 As String
FileOpen(1, "C:\logfile.txt", OpenMode.Output)
tcpClient1.Connect(MyEndPoint1)
NS = tcpClient1.GetStream
ReDim bytes(tcpClient1.ReceiveBufferSize)
buffsize = CInt(tcpClient1.ReceiveBufferSize)
If NS.DataAvailable Then
NS.Read(bytes, 0, buffsize)
buff2 = Encoding.ASCII.GetString(bytes)
Print(1, buff2)
End If
FileClose(1)
End Sub
End Module
 
Back
Top