在UDP客户端执行后:
socket.SendTo(data, SendIP);
为什么socket.LocalEndPoint会改变?
最佳答案
如果您从未调用过 socket.Bind,那么在第一次传输时,UDP 堆栈将自动为您分配一个本地地址。
引自MSDN:
If you are using a connectionless protocol, you do not need to establish a default remote host with the Connect method prior to calling SendTo. ... .You are also not required to call the Bind method, because the underlying service provider will assign the most appropriate local network address and port number.
关于C# 套接字 : Why does socket. LocalEndPoint 更改?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2757660/