gpt4 book ai didi

C# 套接字 : Why does socket. LocalEndPoint 更改?

转载 作者:行者123 更新时间:2023-11-30 22:46:10 25 4
gpt4 key购买 nike

执行后在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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com