【发布时间】:2021-06-07 19:06:11
【问题描述】:
我正在尝试在客户端和服务器之间实现 UDP 网络,但在许多实现中,它们使用 send() 或 sendTo() 我尝试查看手册页,但我并没有真正理解其他的区别与sendTo() 相比,sendTo() 接受更多参数,这使得它与send() 相比显得相当无用。如果您能对此事提出任何澄清,我会很高兴听到:)
【问题讨论】:
-
来自精美手册:
The send() call may be used only when the socket is in a connected state (so that the intended recipient is known). -
你可能想要
sendto。 “额外参数”使它适用于 UDP 无连接数据报。您仍然使用套接字,但 sendto 会为您绑定到指定的目标、删除消息、然后取消绑定等。简而言之,没有connect客户端。 -
sendTo()不存在。你的意思是sendto()。
标签: c sockets networking udp