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

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

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

     public static void StartClient()
            {
                // Data buffer for incoming data.
                byte[] bytes = new byte[1024];

                // Connect to a remote device.
                try
                {
                    // Establish the remote endpoint for the socket.
                    // This example uses port 11000 on the local computer.
                    IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName());
                    IPAddress ipAddress = ipHostInfo.AddressList[0];
                    IPEndPoint remoteEP = new IPEndPoint(ipAddress, 11000);

                    // Create a TCP/IP  socket.
                    Socket sender = new Socket(AddressFamily.InterNetwork,
                       SocketType.Stream, ProtocolType.Tcp);
                    // Connect the socket to the remote endpoint. Catch any errors.
                    try
                    {
                        sender.Connect(remoteEP);

                        Console.WriteLine("Socket connected to {0}",
                           sender.RemoteEndPoint.ToString());

                        string tempStr = GetContent(Console.ReadLine());
                        while (true)
                        {

                      

                       
                            Console.WriteLine("輸入信息");


                            // Encode the data string into a byte array.
                            byte[] msg = Encoding.GetEncoding("gb2312").GetBytes(tempStr + "<EOF>");


                            // Send the data through the socket.
                            int bytesSent = sender.Send(msg);

                            // Receive the response from the remote device.
                            int bytesRec = sender.Receive(bytes);
                            Console.WriteLine("Echoed test = {0}",
                                Encoding.ASCII.GetString(bytes, 0, bytesRec));
                     
                            Console.WriteLine("輸入信息 輸入e退出");
                            tempStr = GetContent(Console.ReadLine());
                             if (tempStr == "e")
                                 break;
                        }
                        // Release the socket.
                        sender.Shutdown(SocketShutdown.Both);
                        sender.Close();

                    }
                    catch (ArgumentNullException ane)
                    {
                        Console.WriteLine("ArgumentNullException : {0}", ane.ToString());
                    }
                    catch (SocketException se)
                    {
                        Console.WriteLine("SocketException : {0}", se.ToString());
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Unexpected exception : {0}", e.ToString());
                    }

                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }
               
            }  

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

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


    網站導航:
     

    常用鏈接

    留言簿(5)

    隨筆分類

    隨筆檔案

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲一区二区三区高清在线观看| 精品亚洲麻豆1区2区3区| 亚洲人成自拍网站在线观看| 91精品免费久久久久久久久| 亚洲福利视频一区二区三区| 91精品国产免费久久国语麻豆| 亚洲av日韩av激情亚洲| 美丽姑娘免费观看在线观看中文版 | 亚洲高清成人一区二区三区| 精品在线免费视频| 免费A级毛片无码A| 美女视频黄频a免费| 亚洲精品国产综合久久一线| 日本高清免费中文在线看| 免费人成网站7777视频| 亚洲av成本人无码网站| 国产一级一片免费播放| 有码人妻在线免费看片| 国产亚洲一区二区精品| 日本免费一区二区三区| 一本色道久久88—综合亚洲精品| 日韩电影免费在线| 韩国免费a级作爱片无码| 亚洲国产成人私人影院| 四虎精品视频在线永久免费观看| 99久久国产亚洲综合精品| 亚洲а∨天堂久久精品| 国产麻豆一精品一AV一免费| 亚洲AV电影天堂男人的天堂| 久久久久亚洲av无码专区导航| 亚洲国产精品免费观看| 亚洲va中文字幕| 亚洲AV无码乱码在线观看裸奔| 日本黄网站动漫视频免费| 99亚洲精品卡2卡三卡4卡2卡| 国产午夜亚洲精品理论片不卡| 久久综合给合久久国产免费| 亚洲日本VA中文字幕久久道具| 亚洲午夜av影院| 91成人免费观看网站| 毛片亚洲AV无码精品国产午夜|