int WINS_OpenSocket(int port) { int newsocket; struct sockaddr_in address; u_long _true = 1; if ((newsocket = psocket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) { return -1; } if (pioctlsocket(newsocket, FIONBIO, &_true) == -1) { goto ErrorReturn; } address.sin_family = AF_INET; address.sin_addr.s_addr = myAddr; address.sin_port = htons((unsigned short)port); if (bind(newsocket, (void *)&address, sizeof(address)) == 0) { return newsocket; } Sys_Error("Unable to bind to %s", WINS_AddrToString((struct qsockaddr *)&address)); ErrorReturn: pclosesocket(newsocket); return -1; }
int WIPX_CheckNewConnections (void) { unsigned long available; if (net_acceptsocket == -1) return -1; if (pioctlsocket (ipxsocket[net_acceptsocket], FIONREAD, &available) == -1) Sys_Error ("WIPX: ioctlsocket (FIONREAD) failed\n"); if (available) return net_acceptsocket; return -1; }
int WIPX_OpenSocket ( int port ) { int handle; int newsocket; struct sockaddr_ipx address; u_long _true = 1; for (handle = 0; handle < IPXSOCKETS; handle++) if (ipxsocket[handle] == 0) break; if (handle == IPXSOCKETS) return -1; if ((newsocket = psocket (AF_IPX, SOCK_DGRAM, NSPROTO_IPX)) == INVALID_SOCKET) return -1; if (pioctlsocket (newsocket, FIONBIO, &_true) == -1) goto ErrorReturn; if (psetsockopt(newsocket, SOL_SOCKET, SO_BROADCAST, (char *)&_true, sizeof(_true)) < 0) goto ErrorReturn; address.sa_family = AF_IPX; memset(address.sa_netnum, 0, 4); memset(address.sa_nodenum, 0, 6);; address.sa_socket = htons((unsigned short)port); if( bind (newsocket, (void *)&address, sizeof(address)) == 0) { ipxsocket[handle] = newsocket; sequence[handle] = 0; return handle; } Sys_Error ("Winsock IPX bind failed\n"); ErrorReturn: pclosesocket (newsocket); return -1; }
int WINS_OpenSocket (int port) { int newsocket; struct sockaddr_in address; u_long _true = 1; if ((newsocket = psocket (PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) return -1; if (pioctlsocket (newsocket, FIONBIO, &_true) == -1) goto ErrorReturn; address.sin_family = AF_INET; address.sin_addr.s_addr = INADDR_ANY; address.sin_port = htons((unsigned short)port); if( bind (newsocket, (void *)&address, sizeof(address)) == 0) return newsocket; Sys_Error ("bind"); ErrorReturn: pclosesocket (newsocket); return -1; }