linux绑定错误代码,linux – 套接字绑定失败errno = 99
我正在尝试绑定服务器套接字,以便我可以接收和侦听来自其他客户端的传入消息.但我无法绑定,它返回一个错误 – 套接字绑定失败:99.我读了它的意思,它说errno 99表明套接字不存在?有任何想法吗?谢谢@H_403_2@UDP_socketID = socket(AF_INET,SOCK_DGRAM,0);if (UDP_socketID < 0){printf("Socket creati
我正在尝试绑定服务器套接字,以便我可以接收和侦听来自其他客户端的传入消息.但我无法绑定,它返回一个错误 – 套接字绑定失败:99.我读了它的意思,它说errno 99表明套接字不存在?有任何想法吗?谢谢
@H_403_2@UDP_socketID = socket(AF_INET,SOCK_DGRAM,0);
if (UDP_socketID < 0)
{
printf("Socket creation Failed! Error = %d\n\n",errno);
exit(0);
}
//specify server address,port and IP
bzero((char *)&serverAddr,sizeof(serverAddr));
serverAddr.sin_family = AF_INET;
serverAddr.sin_addr.s_addr = htonl(INADDR_ANY);
serverAddr.sin_port = htons(SERV_PORT);
check = inet_aton(SERVER_IP,&serverAddr.sin_addr);
if (check == 0)
printf("IP conversion error!\n\n");
start = bind(UDP_socketID,(struct sockaddr *) &serverAddr,sizeof(serverAddr));
if (start < 0) {
printf("Socket bind Failed = %d\n",errno);
exit(0);
}
else
printf("Socket bind successful!\n");
99是EADDRNOTAVAIL.这意味着(来自man bind(2)):
A nonexistent interface was requested or the requested address was not
local.
也许SERVER_IP不是您主机的IP.
更多推荐
所有评论(0)