UdpClient.Recieve()问题 [英] UdpClient.Recieve() problem
本文介绍了UdpClient.Recieve()问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从错误的论坛复制粘贴:
我正在尝试创建一个简单的udp聊天客户端来了解网络
连接。据我所知,从互联网上看,
我已经正确配置了所有内容。但是,似乎有一个
发送和接收问题 - 也就是说,它没有发生。
我的接收循环(在一个线程中运行):
public void Listener() |
{ |
System.Net.Sockets .UdpClient udpClient = new System.Net.Sockets.UdpClient(); |
udpClient.Connect( new IPEndPoint( new IPAddress( new byte [] {192,168,0,101}),5417)); |
// udpClient.Connect(ipEndPoint); |
做 |
{ |
byte [] buffer = udpClient.Receive( ref ipEndPoint); |
for ( int t = 0; t< buffer.GetLength(0); ++ t) |
{ |
Program.form1.chatHistoryTextBox。文字+ =(( char )(buffer [t])); |
} |
} |
而 (1 == 1); |
} |
解决方案
< blockquote>您的客户端是否发送到5417端口?什么是"端点"?
-Steve
Copy-paste'd from the wrong forum:
I'm trying to make a simple udp chat client to learn about network
connections. As far as I can tell from looking around the internet,
I've got everything configured properly. However, there seems to be a
send and receive problem - That is, it isn't happening.
My receive loop (Run in a thread):
public void Listener() |
{ |
System.Net.Sockets.UdpClient udpClient = new System.Net.Sockets.UdpClient(); |
udpClient.Connect(new IPEndPoint(new IPAddress(new byte[] { 192, 168, 0, 101 }), 5417)); |
// udpClient.Connect(ipEndPoint); |
do |
{ |
byte[] buffer = udpClient.Receive(ref ipEndPoint); |
for (int t = 0; t < buffer.GetLength(0); ++t) |
{ |
Program.form1.chatHistoryTextBox.Text += ((char)(buffer[t])); |
} |
} |
while (1 == 1); |
} |
解决方案
Is your client sending to port 5417? What is "endpoint"?
-Steve
这篇关于UdpClient.Recieve()问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文