头文件:
#include <sys/types.h> /* See NOTES */
#include <sys/socket.h>
函数原型:
int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
函数说明:
当通过socket来创建一个套接字时,套接字本身存在于一个命名空间中,但并没有为它分配地址。使用bind()函数可以将addr地址指定给文件描述符sockfd。其中addrlen指定了addr地址指针的大小。