accept(接受socket连线)
#include <sys/socket.h> int accept(int socket, struct sockaddr *restrict address, socklen_t *restrict address_len);
bind(对socket定位)
#include <sys/socket.h> int bind(int socket, const struct sockaddr *address, socklen_t address_len);
connect(建立socket连线)
#include <sys/socket.h> int connect(int socket, const struct sockaddr *address, socklen_t address_len);
endprotoent(结束网络协议数据的读取)
#include <netdb.h> void endprotoent(void);
endservent(结束网络服务数据的读取)
#include <netdb.h> void endservent(void);
gethostbyaddr(由ip地址取得网络数据)
#include <sys/socket.h>/* for AF_INET */ struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type);
gethostbyname(由主机名称取得网络数据)
#include <netdb.h> struct hostent *gethostbyname(const char *name);
getprotobyname(由网络协议名称取得协议数据)
#include <netdb.h> struct protoent *getprotobyname(const char *name);
getprotobynumber(由网络协议编号取得协议数据)
#include <netdb.h> struct protoent *getprotobynumber(int proto);
getprotoent(取得网络协议数据)
#include <netdb.h> struct protoent *getprotoent(void);
getservbyname(依名称取得网络服务的数据)
#include <netdb.h> struct servent *getservbyname(const char *name, const char *proto);
getservbyport(依port号码取得网络服务的数据)
#include <netdb.h> struct servent *getservbyport(int port, const char *proto);
getservent(取得主机网络服务的数据)
#include <netdb.h> struct servent *getservent(void);
getsockopt(取得socket状态)
#include <sys/types.h> /* See NOTES */ #include <sys/socket.h> int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen);
herror(打印出网络错误原因信息字符串)
#include <sys/socket.h> void herror(const char *s);
hstrerror(返回网络错误原因的描述字符串)
#include <sys/socket.h> const char *hstrerror(int err);
htonl(将32位主机字符顺序转换成网络字符顺序)
#include <arpa/inet.h> uint32_t htonl(uint32_t hostlong);
htons(将16位主机字符顺序转换成网络字符顺序)
#include <arpa/inet.h> uint16_t htons(uint16_t hostshort);
inet_addr(将网络地址转成网络二进制的数字)
#include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> in_addr_t inet_addr(const char *cp);
inet_aton(将网络地址转成网络二进制的数字)
#include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> int inet_aton(const char *cp, struct in_addr *inp);
inet_ntoa(将网络二进制的数字转换成网络地址)
#include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> char *inet_ntoa(struct in_addr in);
listen(等待连接)
#include <sys/socket.h> int listen(int socket, int backlog);
ntohl(将32位网络字符顺序转换成主机字符顺序)
#include <arpa/inet.h> uint32_t ntohl(uint32_t netlong);
ntohs(将16位网络字符顺序转换成主机字符顺序)
#include <arpa/inet.h> uint16_t ntohs(uint16_t netshort);
recv(经socket接收数据)
#include <sys/socket.h> ssize_t recv(int socket, void *buffer, size_t length, int flags);
recvfrom(经socket接收数据)
#include <sys/socket.h> ssize_t recvfrom(int socket, void *restrict buffer, size_t length, int flags, struct sockaddr *restrict address, socklen_t *restrict address_len);
recvmsg(经socket接收数据)
#include <sys/socket.h> ssize_t recvmsg(int socket, struct msghdr *message, int flags);
send(经socket传送数据)
#include <sys/socket.h> ssize_t send(int socket, const void *buffer, size_t length, int flags);
sendmsg(经socket传送数据)
#include <sys/socket.h> ssize_t sendmsg(int socket, const struct msghdr *message, int flags);
sendto(经socket传送数据)
#include <sys/socket.h> ssize_t sendto(int socket, const void *message, size_t length, int flags, const struct sockaddr *dest_addr, socklen_t dest_len);
setprotoent(打开网络协议的数据文件)
#include <netdb.h> void setprotoent(int stayopen);
setservent(打开主机网络服务的数据文件)
#include <netdb.h> void setservent(int stayopen);
setsockopt(设置socket状态)
#include <sys/types.h> /* See NOTES */ #include <sys/socket.h> int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen);
shutdown(终止socket通信)
#include <sys/socket.h> int shutdown(int socket, int how);
socket(建立一个socket通信)
#include <sys/socket.h> int socket(int domain, int type, int protocol);