套接字侦听器在启动时不起作用

时间:2015-07-09 10:32:15

标签: c# sockets udp

我创建了一个套接字侦听器,它从特定端口读取数据,如果我运行此应用程序单击exe,则可以正常工作。但是当它从窗口启动运行时,套接字监听器无法从套接字读取数据。

以下代码位于 Form1_Load 函数

UdpClient udpClient = new UdpClient(8010);
while (true)
{
    IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);
    Byte[] receiveBytes = udpClient.Receive(ref RemoteIpEndPoint);
    string returnData = Encoding.ASCII.GetString(receiveBytes);

}

0 个答案:

没有答案
相关问题