UDP 通讯中 接收byte的时候停止了!!

xiaoyao1212121 xiaoyao1212121 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
void ReceiveMessage()
{
//UdpClientB = new UdpClient(portclient); //B开启的端口号
//remotePoint = new IPEndPoint(IPAddress.Any, 0);
int recv;
byte[] bytes = new byte[1024];

IPEndPoint ipt = new IPEndPoint(IPAddress.Any, 13000);
Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
server.Bind(ipt);

while (true)
{
try
{
IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);
EndPoint Remote = (EndPoint)(sender);
recv = server.ReceiveFrom(bytes, ref Remote);

MessagePP com = (MessagePP)DeserializeObject(bytes);
if (com.command == 0)
{
ReceivedACK = true;
}
else
{
//收的都是图片了
MessageBox.Show("B已经收到了A发来的图片消息了");
}

}
catch
{

}
}
}


单步调试,到了红色的那行代码处,没有继续往下运行了.....求助...正在弄UDP打洞,这个为Client,监听着自己这边的一个端口,然后要得到其他Client发过来的数据
...全文
评论 10
收藏 已收藏
分享
返回顶部
xiaoyao1212121
C# 111,129 成员 642,540 内容