
Signature
Filip
http://www.ww2airborne.net/
Official Site of the 101st Airborne - 463rd PFA
skype: airborne463pfa-fiwi
[It's nice to be important, but it's more important to be nice!]
----------------------------------------------------------------
Hi,
System.Net.Sockets.TcpClient is the class name.
You would open a TCP/IP socket (the TcpClient) using the telnet server
Address and Port(typically, port 23, but some servers may use another port
number) as a stream
You then set a TextWriter to use the stream just opened and write your
output using the TextWriter Write method. You can use Thread.Sleep to add a
delay after the Write.
Dick

Signature
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
Screaming Eagles 101 - 16 Oct 2007 08:56 GMT

Signature
Filip
http://www.ww2airborne.net/
Official Site of the 101st Airborne - 463rd PFA
skype: airborne463pfa-fiwi
[It's nice to be important, but it's more important to be nice!]
----------------------------------------------------------------
> Hi,
>
[quoted text clipped - 9 lines]
>
> Dick
OK thanks, I looked up things in that direction,
and I found something useful, which seems to work.
Imports System.Net.Sockets
Imports System.Text
Public Class Form1
Private oTCPStream As Net.Sockets.NetworkStream
Private oTCP As New Net.Sockets.TcpClient()
Private bytWriting As [Byte]()
Private bytReading As Byte()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Try
TextBox1.Text = ""
oTCP.SendTimeout = 1500
oTCP.Connect("999.99.99.9", "259")
oTCPStream = oTCP.GetStream
TextBox1.Text = TextBox1.Text & ReadData() & vbCrLf
WriteData("myusername" & vbCrLf)
System.Threading.Thread.Sleep(500)
TextBox1.Text = TextBox1.Text & ReadData() & vbCrLf
WriteData("mypassword" & vbCrLf)
System.Threading.Thread.Sleep(1000)
TextBox1.Text = TextBox1.Text & ReadData() & vbCrLf
WriteData("1" & vbCrLf)
TextBox1.Text = TextBox1.Text & ReadData() & vbCrLf
oTCPStream.Close()
oTCP.Close()
MsgBox("connection ok")
Catch Err As Exception
MsgBox(Err.ToString)
End Try
End Sub
Private Function ReadData() As String
Dim sData As String
ReDim bytReading(oTCP.ReceiveBufferSize)
oTCPStream.Read(bytReading, 0, oTCP.ReceiveBufferSize)
sData = Trim(System.Text.Encoding.ASCII.GetString(bytReading))
ReadData = sData
End Function
Private Sub WriteData(ByVal sData As String)
bytWriting = System.Text.Encoding.ASCII.GetBytes(sData)
oTCPStream.Write(bytWriting, 0, bytWriting.Length)
End Sub