Datagram winsock programming in VC++ 5.0
Posted on 1998-04-13
I have a problem with configuring a socket to receive data on a datagram (connectionless) mode.
The other computer will send out a broadcast on port 0x5050 with a specific data field, so I do not know what MAC address to connect to.
The error listen() returns is WSAEOPNOTSUPP, which means the socket doesn't support listening... which I need to do.
The following lines are from my program, please tell me what I'm doing wrong or what I am missing.
MonitorReceiveString[i] = '0';
MonitorRecvSocket = socket(AF_IPX, SOCK_DGRAM, NSPROTO_IPX);
MonitorRecvSocketAddress.sa_family = AF_IPX;
MonitorRecvSocketAddress.sa_nodenum[i] = 'ÿ'; //ÿ = 0xFF for broadcast
MonitorRecvSocketAddress.sa_socket = 0x5050;
MonitorSendSocketAddress.sa_netnum[i] = 0x00;
if(bind(MonitorRecvSocket, (struct sockaddr *)&MonitorRecvSocketAddress, sizeof(MonitorRecvSocketAddress)) == SOCKET_ERROR)
if(listen(MonitorRecvSocket, 15) == SOCKET_ERROR)