February 24th, 2009, 04:00 PM
Problem of UDP broadcast on the mult-interfaces
I try to broadcast UDP packet on a mult interfaces computer with windows XP.
one IP is 169.254.99.59 and another is 169.254.34.213.
when the both are connected to network, the broadcast is only through the IP 169.254.99.59, even i bind the local address to IP 169.254.34.213.
when I disconnect the interface of 169.254.99.59, the broadcast is through the IP 169.254.34.213. I used the wireshark to check the both interface message. Does anyone have idea? thanks ahead.
BYTE pBuf ="This is broadcast test code!"
Broadcastsocket = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
setsockopt(Broadcastsocket, SOL_SOCKET, SO_BROADCAST, (char*)&bOptVal, bOptLen);
Local_socketAddr.sin_family = AF_INET;
Local_socketAddr.sin_addr.s_addr = inet_addr("169.254.34.213");
//or Local_socketAddr.sin_addr.s_addr = INADDR_ANY;
Local_socketAddr.sin_port = htons(45234);
bind( Broadcastsocket, Local_socketAddr, sizeof(Local_socketAddr));
Remote_socketAddr.sin_family = AF_INET;
Remote_socketAddr.sin_addr.s_addr = INADDR_BROADCAST;
Remote_socketAddr.sin_port = htons(45235);
sendto( Broadcastsocket, (const char*)pBuf, strlen(pBuf), 0, (SOCKADDR*) &Remote_socketAddr, sizeof(Remote_socketAddr) );
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!