-
February 24th, 2009, 05:00 PM
#1
Problem of UDP broadcast on the mult-interfaces
Hi,
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.
code is:
BYTE pBuf[] ="This is broadcast test code!"
SOCKET Broadcastsocket;
sockaddr_in Local_socketAddr,Remote_socketAddr;
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);
Remote_socketAddr.
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|