http://ip.qq.com/cgi-bin/myip
高手们。谁能用。NET里的webclient或者.net里其他的类。
发送IP地址,并返回数据。
那位大虾搞哈看。行不!

解决方案 »

  1.   


    不就是发送searchip1-searchip4这4个数字吗?
      

  2.   

                WebClient wc = new WebClient();
                NameValueCollection vc = new NameValueCollection();
                vc.Add("searchip1","202");
                vc.Add("searchip2","181");
                vc.Add("searchip3","6");
                vc.Add("searchip4","18");            byte[] buff = wc.UploadValues("http://ip.qq.com/cgi-bin/searchip", vc);
                Console.WriteLine(Encoding.Default.GetString(buff));
      

  3.   

     客户端
    //发送数据
                    TcpClient client = new TcpClient(textBox3.Text.Trim()/*ip地址*/, Convert.ToInt32(textBox4.Text.Trim())/*端口*/); //5567
                    //文件流
                    NetworkStream sendStream = client.GetStream();
                    //StreamWriter writer = new StreamWriter(sendStream);
                    //发送的内容
                    String msg = textBox2.Text;
                    //转换为数组
                    Byte[] sendBytes = Encoding.Default.GetBytes(msg);
                    //发送
                    sendStream.Write(sendBytes, 0, sendBytes.Length);
                    
                  //接收返回数据流
                    byte[] bytes = new byte[2048];
                    //接收
                    sendStream = client.GetStream();                
                    int bytesread = sendStream.Read(bytes, 0, bytes.Length);
                    //将数据流转换成字符串
                    string reciveMsg = Encoding.Default.GetString(bytes, 0, bytesread);            
                    sendStream.Close();
                    client.Close();
    //服务器端