Linux系统调用之send/sendto/sendmsg函数解析

Linux大全评论688 views阅读模式

【send/sendto/sendmsg系统调用】 
   
功能描述:
发送消息。send只可用于基于连接的套接字,send 和 write唯一的不同点是标志的存在,当标志为0时,send等同于write。sendto 和 sendmsg既可用于无连接的套接字,也可用于基于连接的套接字。除了套接字设置为非阻塞模式,调用将会阻塞直到数据被发送完。
 
用法:
#include <sys/types.h>
#include <sys/socket.h>

ssize_t send(int sock, const void *buf, size_t len, int flags);
ssize_t sendto(int sock, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen);
ssize_t sendmsg(int sock, const struct msghdr *msg, int flags);

企鹅博客
  • 本文由 发表于 2019年9月21日 06:14:07
  • 转载请务必保留本文链接:https://www.qieseo.com/131329.html

发表评论