国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

C#超級簡單的Telnet(TcpClient)客戶端

2019-11-14 16:00:43
字體:
來源:轉載
供稿:網友

基于Sockets

沒什么好說的,代碼說明了所有

 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Net.Sockets; 6 using System.IO; 7  8 namespace Consoleapplication1 9 {10     class PRogram11     {12         public static NetworkStream stream;13         public static TcpClient tcpclient;14         public static string ip;15         public static  int port;16         static void Main(string[] args)17         {18             Console.WriteLine("目標IP:");19             ip = Console.ReadLine();20             Console.WriteLine("目標Port:");21             port =int.Parse(Console.ReadLine());22 23             Run();24         }25 26         static public void Run()27         {28             tcpclient = new TcpClient(ip, port);  // 連接服務器29             stream = tcpclient.GetStream();   // 獲取網絡數據流對象30             StreamWriter sw = new StreamWriter(stream);31             StreamReader sr = new StreamReader(stream);32             while (true)33             {34                 //Read Echo35                 //Set ReadEcho Timeout36                 stream.ReadTimeout = 10;37                 try38                 {39                     while (true)40                     {                        41                             char c = (char)sr.Read();42                             if (c < 256)43                             {44                                 if (c == 27)45                                 {46                                     while (sr.Read() != 109) { }47                                 }48                                 else49                                 {50                                     Console.Write(c);51                                 }52                             }53                     }54                 }55                 catch56                 {57                     58                 }59                 //Send CMD60                 sw.Write("{0}/r/n", Console.ReadLine());61                 sw.Flush();62             }63         }64 65     }66 }
TcpClient

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 阿荣旗| 维西| 伊宁县| 虎林市| 柳林县| 达日县| 金山区| 三台县| 六枝特区| 涟水县| 新丰县| 阆中市| 封丘县| 东丽区| 海晏县| 合作市| 绥江县| 陈巴尔虎旗| 英超| 六枝特区| 梅河口市| 正宁县| 新野县| 都匀市| 武夷山市| 图木舒克市| 平安县| 女性| 嵩明县| 璧山县| 葵青区| 理塘县| 安多县| 怀远县| 葫芦岛市| 尚义县| 新郑市| 洛川县| 南汇区| 定襄县| 靖江市|