Hi,
I am having problems with the 2.4 Kernel (SuSE 8.2 and RedHat 9). The
code below sends a multicast message and works fine on RedHat 6,
RedHat 7.2, SuSE 7 and SuSE 8.0. On SuSE 8.2 and RedHat 9 it returns
the error "Network is unreachable"
Can anyone help please?
Best Regards
Keith
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define MULTICAST_ADDRESS 0xefc0409a
#define CONTROL_STARTUP ((unsigned char)'\x15')
int main(void)
{
int MulticastSocket = 0;
int Port = 4950;
unsigned char buffer[20];
unsigned char *header = buffer;
unsigned char *body = buffer + 16;
size_t NumBytes = 0;
struct sockaddr_in to;
MulticastSocket = socket(AF_INET,SOCK_DGRAM,0);
if (MulticastSocket < 0)
{
printf("ERROR: socket() returned %d,error = %s\n",
MulticastSocket,strerror(errno));
return;
}
memset(header,'\0',16);
header[0] = CONTROL_STARTUP;
header[10] = 0x00;
*((uint *)body) = htonl((uint)getpid());
/*
** Set up the destination address
*/
memset(&to,'\0',sizeof(to));
to.sin_family = AF_INET;
to.sin_port = htons(Port);
to.sin_addr.s_addr = htonl(MULTICAST_ADDRESS);
errno = 0;
NumBytes = sendto(MulticastSocket,buffer,sizeof(buffer),
0, /* flags - none set */
&to,sizeof(to));
if ((int)NumBytes < 0)
{
printf("ERROR: sendto() returned %d,error = %s\n",
NumBytes,strerror(errno));
}
close(MulticastSocket);
Quote:}