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

标签 c# sockets udp

在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/

相关文章:

c# - 使用 HtmlAgilityPack 的 doctype 问题

c# - 使用依赖于另一个属性的属性初始化对象

c# - 将进度条绑定(bind)到 wpf 中的媒体元素

sockets - 通过浏览器呈现网页

c - 具有多个客户端的 UDP 客户端服务器

linux - 用于多个以太网端口的多个 udp 套接字

linux - 两个进程共享同一个 UDP 端口发送

c# - 每个方法的线程同步锁定

node.js - 跨多个 Amazon EC2 实例水平扩展 socket.io

java - 通过UDP发送图片