Hello all,
I would like to doing a UDP broadcast via port 3000. For linux boxes with one
network
interface card everything works as expected. But if the box has two or more
cards, these are
ignored and the broadcast is further send only via the first interface. My code
is attached at the end.
Do I need some special to go over all interfaces available on a linux box ?
--
------------------------
Thanks in advance
Lars Gsmar
here is the code:
int i = 1;
static DWORD dwLocalAddr = 0;
static u_short PortStatus = 3000;
static int UpSocket;
char szBuffer[1024],
struct sockaddr_in addr;
#define StrUp "This is the broadcast message"
addr.sin_port = htons(PortStatus);
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = (DWORD) -1;
UpSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
setsockopt(UpSocket, SOL_SOCKET, SO_BROADCAST, (LPSTR)&i,sizeof(i));
bind(UpSocket, &addr, sizeof(addr));
if (sendto(UpSocket, StrUp, sizeof(StrUp) + 1, 0, (LPSOCKADDR)&addr,
sizeof(addr)) == -1)
{
Message("Broadcast failed!\n");
}