我正在尝试绑定服务器套接字,以便可以接收和侦听来自其他客户端的传入消息。但我无法绑定,它返回一个错误 - 套接字绑定失败:99。我读了它是什么意思,它说 errno 99 表示套接字不存在?有任何想法吗?谢谢
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");