<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 閱讀(433) 評論(0)  編輯  收藏

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


    網站導航:
    博客園   IT新聞   Chat2DB   C++博客   博問  
     

    常用鏈接

    留言簿(5)

    隨筆分類

    隨筆檔案

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲中文字幕久在线| 久久国产精品亚洲综合| 伊人久久亚洲综合影院首页| 亚洲黄色免费观看| 亚洲精品乱码久久久久久下载| 免费91最新地址永久入口| 亚洲日产韩国一二三四区| h视频在线免费观看| 国产亚洲自拍一区| av网站免费线看| 国产国拍亚洲精品mv在线观看 | 久久亚洲AV成人无码国产| 久久久久久AV无码免费网站下载 | 嫖丰满老熟妇AAAA片免费看| 亚洲喷奶水中文字幕电影| 妞干网手机免费视频| 亚洲国产精品无码久久98| 免费看小12萝裸体视频国产| 免费人成网上在线观看| 亚洲色精品aⅴ一区区三区| 免费人成毛片动漫在线播放| 亚洲黄色片免费看| 全免费a级毛片免费看不卡| 猫咪免费观看人成网站在线| 亚洲伊人久久大香线蕉综合图片| 国产高清不卡免费视频| 亚洲xxxx18| 亚洲人成网站色在线入口| 久久爰www免费人成| 亚洲AV无码专区在线亚| 四虎永久免费影院| 国产高清不卡免费视频| 亚洲综合小说另类图片动图 | 男人的天堂亚洲一区二区三区 | 国产成人精品日本亚洲18图| 午夜免费福利网站| 最近免费中文字幕MV在线视频3 | 亚洲变态另类一区二区三区 | 毛片免费视频观看| 国产高潮流白浆喷水免费A片 | 中文字幕亚洲精品资源网|