首页 > 其他分享 >difference between send() and sendTo() in C for a UDP network implementation

difference between send() and sendTo() in C for a UDP network implementation

时间:2022-12-16 14:47:55浏览次数:44  
标签:function UDP network implementation IP send connect port

The sendto function is the one that's generally used for UDP sockets. As UDP is connectionless, this function allows you to specify the IP and port that each outgoing packet is sent to.

You can however also use send if you first use connect. The connect function can be used to specify the destination IP and port for all packets sent using send. It also restricts the packets you receive to just those from that IP/port. The connect function may be called multiple times to change the associated remote IP/port, or to remove the association.

In general, I would recommend sticking with sendto as it gives you more flexibility over who you're sending to.

标签:function,UDP,network,implementation,IP,send,connect,port
From: https://www.cnblogs.com/fire909090/p/16987300.html

相关文章