创建
socket
int socket(int domain, int type, int protocol);
命名/绑定
bind
int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
监听
listen
int listen(int sockfd, int backlog);
发送连接(主动)
connect
int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
接收连接(被动)
accept
int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
读写数据
send/recv
ssize_t send(int sockfd, const void *buf, size_t len, int flags);
ssize_t recv(int sockfd, void *buf, size_t len, int flags);
sendto/recvfrom
ssize_t sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen);
ssize_t recvfrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen);
sendmsg/recvmsg
ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags);
ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags);
write/read
ssize_t write(int fd, const void *buf, size_t count);
ssize_t read(int fd, void *buf, size_t count);
关闭连接(主动)
close
int close(int fd);
shutdown
int shutdown(int sockfd, int how);