connecting to Telnet through C#  
Author Message
Fradam





PostPosted: .NET Framework Networking and Communication, connecting to Telnet through C# Top

I am trying to create a Telnet session from a C# application and be able to send commands and receive output back. Is this possible with just a regular TCPClient connecting to a host on port 23 and then reading from/writing to the stream associated with that client This is what I have been trying and can't figure out if my username/password stuff works right, thats why I didn't post any code because i really dont think I have anything that works.

Any help on this would be greatly appreciated.

Thanks in advance


.NET Development15  
 
 
Brendan Grant





PostPosted: .NET Framework Networking and Communication, connecting to Telnet through C# Top

You are exactly right. Telnet is one of those ridiculously simply things that for the most part is just an open port... the authentication though is something else completely as that is up to the shell that you are accessing, not so much the telnet protocol itself.

Are you receiving any data in your client from the server



 
 
Fradam





PostPosted: .NET Framework Networking and Communication, connecting to Telnet through C# Top

I just have a very simple setup right now as follows...

TcpClient telnet = new TcpClient("10.5.6.59", 23);
NetworkStream telnetStream = telnet.GetStream();
StreamWriter output = new StreamWriter(telnetStream);
StreamReader input = new StreamReader(telnetStream);


And I try to read from the stream and it gives me: #'$

when I just do a Console.Write to what is read into my buffer in the input.Read() call.


On a side note, do you have any idea how to do the authentication or how to figure out a way to do it Because since you said that I am guessing that sending in a username/password over the Socket doesnt authenticate me at all and thus I am really not even connected to anything.

I don't know if any of what I said made much sense, sorry if I just confuse you more.

I appreciate the help though