字节序
uint32_t htonl(uint32_t hostlong);
uint16_t htons(uint16_t hostshort);
uint32_t ntohl(uint32_t netlong);
uint16_t ntohs(uint16_t netshort);
分析:其中,函数名字中的 h 表示 host(本机),n 表示 network(网络),而 l 表示要转换的数据是 4 字节,s 表示要转换的数据是 2 字节。
1. socket:
int socket(int domain, int type, int protocol);
2. 函数bind
int bind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen);