Hi,
I'm trying to send an UDP Broadcast package on all Ethernet interfaces on a MacPro1,1 with OS/X 10.5 Leopard. "Ethernet 1" and "Ethernet 2" interfaces are enabled, all other Ethernet interfaces are disabled.
The "Ethernet 1" interface is connected to the LAN in our department (and to the Internet from there).
The "Ethernet 2" interface is connected to a local net consisting of a switch with one PC and more other devices.
The problem is:
I want to UDP package to be sent on the "Ethernet 2" interface, but it is only sent on the "Ethernet 1" interface (that is connected to the LAN).
If I boot the MacPro1,1 to OS/X 10.6 Snow Leopard and run the same program, the UDP package is sent on both The "Ethernet 1" and "Ethernet 2" interface!
I I disable "Ethernet 1" the UDP package is sent OK on "Ethernet 2"
The program used to broadcast the UDP package is shown below. It prints “send ok”, but no UDP package is detected on the net connected to "Ethernet 2".
I have Wireshark running on a PC that is connected to the "Ethernet 2", and it shows no UDP packages.
Question:
· What am I doing wrong?
· How do I force the UDP package to be sent on a all Ethernet interfaces in OS/X 10.5 Leopard?
· Can I force the UDP package to be sent on a specific interface?
Thanks in advance
Best regards
Eigil
The program used to broadcast the UDP Package:
"
void UDPBcast( )
{
int sock;
struct sockaddr_in dest;
struct sockaddr_in local;
int broadcast = 1;
printf("Entry\n");
// local end point
local.sin_family = AF_INET;
local.sin_port = 0;
local.sin_addr.s_addr = inet_addr("192.168.1.160"); // the IP address of the interface that the UDP package should be sent on
//local.sin_addr.s_addr = INADDR_ANY; // Tried this also. Doesn't work either
local.sin_len = sizeof(local);
// destination
dest.sin_family = AF_INET;
dest.sin_port = htons(1235);
dest.sin_addr.s_addr = INADDR_BROADCAST;
dest.sin_len = sizeof(dest);
if((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
printf("fail\n");
return -1;
}
if(setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &broadcast, sizeof(broadcast)) < 0) {
printf("error setting socket option\n");
}
if(bind(sock, (struct sockaddr*)&local, sizeof(local)) <0) {
printf("error binding\n");
return -1;
}
if(sendto(sock, "HELLO", sizeof("HELLO"), 0, (struct sockaddr*)&dest, sizeof(dest)) < 0) {
printf("error sending\n");
}
else {
printf("send ok\n");
}
}