<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    // Incoming data from the client.
          public static string data = null;
     
         public static void StartListening() {
            // Data buffer for incoming data.
            byte[] bytes = new Byte[1024];

            // Establish the local endpoint for the socket.
            // Dns.GetHostName returns the name of the
             // host running the application.
             IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName());
            IPAddress ipAddress = ipHostInfo.AddressList[0];
            IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 11000);

            // Create a TCP/IP socket.
            Socket listener = new Socket(AddressFamily.InterNetwork,
                SocketType.Stream, ProtocolType.Tcp );

            // Bind the socket to the local endpoint and
            // listen for incoming connections.
             try {
                listener.Bind(localEndPoint);
                 listener.Listen(10);
     
                // Start listening for connections.
                while (true) {
                    Console.WriteLine("Waiting for a connection");
                     // Program is suspended while waiting for an incoming connection.
                    Socket handler = listener.Accept();
                     data = null;

                    // An incoming connection needs to be processed.
                    while (true) {
                        data = string.Empty;
                         bytes = new byte[1024];
                         int bytesRec = handler.Receive(bytes);
                         data += Encoding.GetEncoding("GB2312").GetString(bytes,0,bytesRec);
                         if (data.IndexOf("<EOF>") > -1) {
                             // Show the data on the console.
                             Console.WriteLine("Text received : {0}", data);
                             continue;
                         }

                         // Echo the data back to the client.
                         byte[] msg = Encoding.ASCII.GetBytes(data);

                         handler.Send(msg);
                     }
     
              
     
                     handler.Shutdown(SocketShutdown.Both);
                     handler.Close();
                 }
               
             } catch (Exception e) {
                Console.WriteLine(e.ToString());
             }
     
             Console.WriteLine("\nPress ENTER to continue");
             Console.Read();
            
         }
     

    posted on 2011-01-11 13:19 sanmao 閱讀(434) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     

    常用鏈接

    留言簿(5)

    隨筆分類

    隨筆檔案

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 人妻丰满熟妇无码区免费| 亚洲综合中文字幕无线码| 色多多A级毛片免费看| 色窝窝免费一区二区三区 | 亚洲电影在线免费观看| 久久精品国产精品亚洲蜜月| 一级做a爰性色毛片免费| 亚洲精品国产高清不卡在线| 成人a毛片免费视频观看| 亚洲国产婷婷香蕉久久久久久| 日日躁狠狠躁狠狠爱免费视频 | 亚洲人成网站色在线观看| 无码人妻一区二区三区免费| 亚洲午夜无码毛片av久久京东热| 日本免费人成黄页在线观看视频 | 永久免费视频网站在线观看| 亚洲图片中文字幕| 成年女人喷潮毛片免费播放| 激情小说亚洲图片| 中文亚洲AV片在线观看不卡| 拍拍拍无挡免费视频网站| 午夜亚洲AV日韩AV无码大全| 97视频免费在线| 亚洲av无码有乱码在线观看| 亚洲色偷偷综合亚洲AV伊人| 国产午夜成人免费看片无遮挡| 久久久久亚洲精品天堂| 免费a级毛片高清视频不卡| 久久精品国产亚洲AV电影网| 国产亚洲精品AA片在线观看不加载| a毛片全部播放免费视频完整18| 亚洲激情在线视频| 在线观看人成网站深夜免费| 久香草视频在线观看免费| 亚洲嫩模在线观看| 女人18毛片a级毛片免费| 99精品免费视频| 亚洲人成自拍网站在线观看| 亚洲一级特黄无码片| 亚洲高清中文字幕免费| 免费人妻精品一区二区三区|