美文网首页
udp中的connect知识

udp中的connect知识

作者: 大飞_2048 | 来源:发表于2019-11-28 17:22 被阅读0次

网络基础
一、问题:
1、udp可以connect么?
2、有什么好处
二、知识整理
UDP两种方案:
1、直接sendto()或recvfrom()
2、先connect()然后send()或recv()
详细的api

int send(int s, const void *msg, size_t len, int flags); 
int sendto(int s, const void *msg, size_t len, int flags, 
const struct sockaddr *to, socklen_t tolen);

int recv(int s, void *buf, size_t len, int flags);
int  recvfrom(int  s, void *buf, size_t len, int flags, 
struct sockaddr *from,  socklen_t *fromlen);

注意一点:
在已经连接的udp的socket上是不能,sendto 和recvform的。

详细参考:
https://www.cnblogs.com/bleopard/p/4004916.html

相关文章

网友评论

      本文标题:udp中的connect知识

      本文链接:https://www.haomeiwen.com/subject/rrnbwctx.html