<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 閱讀(428) 評(píng)論(0)  編輯  收藏

    只有注冊用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     

    常用鏈接

    留言簿(5)

    隨筆分類

    隨筆檔案

    搜索

    •  

    最新評(píng)論

    閱讀排行榜

    評(píng)論排行榜

    主站蜘蛛池模板: 日韩精品久久久久久免费| 亚洲一区免费在线观看| 国产成人精品久久免费动漫 | 久久精品国产免费观看| 国产精品视频免费一区二区三区| 亚洲最大激情中文字幕| 亚洲av乱码一区二区三区 | 黄色免费网站在线看| 久久成人免费大片| 国产精品极品美女免费观看| 亚洲av最新在线网址| 亚洲风情亚Aⅴ在线发布| 久久久免费的精品| 又黄又爽无遮挡免费视频| 老司机亚洲精品影院无码| 特级毛片全部免费播放| 1000部夫妻午夜免费| 亚洲精品第一国产综合精品99| 亚洲va成无码人在线观看| 中国精品一级毛片免费播放| 午夜男人一级毛片免费| 亚洲一级二级三级不卡| 国产日韩AV免费无码一区二区三区| 毛片免费观看的视频在线| 亚洲AV成人一区二区三区AV| 爱情岛论坛免费视频| 在线观看免费人成视频| 亚洲a在线视频视频| 一级午夜a毛片免费视频| 在线观看无码的免费网站| 久久综合亚洲鲁鲁五月天| 国产三级在线免费观看| 国产成人aaa在线视频免费观看| 亚洲精品免费在线| 免费无码又爽又刺激一高潮| 免费不卡中文字幕在线| 亚洲色大成WWW亚洲女子| 国产成人精品免费视频动漫| 亚洲AV永久无码精品| 一级中文字幕乱码免费| 国产不卡免费视频|