Based on sockets
There's nothing to say, the code explains all
1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Text;5 usingSystem.Net.Sockets;6 usingSystem.IO;7 8 namespaceConsoleApplication19 {Ten class Program One { A Public StaticNetworkStream stream; - Public StaticTcpClient TcpClient; - Public Static stringIP; the Public Static intPort; - Static voidMain (string[] args) - { -Console.WriteLine ("Destination IP:"); +IP =console.readline (); -Console.WriteLine ("Destination Port:"); +Port =int. Parse (Console.ReadLine ()); A at Run (); - } - - Static Public voidRun () - { -TcpClient =NewTcpClient (IP, port);//connecting to a server instream = TcpClient. GetStream ();//get a network data flow object -StreamWriter SW =NewStreamWriter (stream); toStreamReader sr =NewStreamReader (stream); + while(true) - { the //Read Echo * //Set Readecho Timeout $Stream. ReadTimeout =Ten;Panax Notoginseng Try - { the while(true) + { A Charc = (Char) Sr. Read (); the if(C < the) + { - if(c = = -) $ { $ while(Sr.) Read ()! =109) { } - } - Else the { - Console.Write (c);Wuyi } the } - } Wu } - Catch About { $ - } - //Send CMD -Sw. Write ("{0}\r\n", Console.ReadLine ()); A SW. Flush (); + } the } - $ } the}
TcpClient
C # Super Simple Telnet (TcpClient) client