哈!webclient或这方面的使用!有难度,高手进! http://ip.qq.com/cgi-bin/myip高手们。谁能用。NET里的webclient或者.net里其他的类。发送IP地址,并返回数据。那位大虾搞哈看。行不! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不就是发送searchip1-searchip4这4个数字吗? 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)); 客户端//发送数据 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();//服务器端 Web用户控件中的自定义事件如何设置才能显示在属性面板上呢? 新手求教简单问题3,但是我不懂! 调试时无法运行,output框里出现这样一段,帮忙啊!! 自定义简单的控件入门,对文本框输入的信息进行限制 .NET窗体相互调用问题! 咋样实现刷新啊??? 蓝桥杯,字符串的输入输出 我时WMI方面的新手,可是说刚刚接触,我需要这方面的书籍 C#程序员的¥为多少? winform 调用 Nhibernate 测试问题 combox与textbox问题请教高手!!!!!!!!!!!!!!! C#套接字的小问题
不就是发送searchip1-searchip4这4个数字吗?
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));
//发送数据
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();
//服务器端