louis.mayencourt@arm.com [nuttx]
2017-09-21 13:27:05 UTC
Hi,
I'm trying to send some UDP packages with a multicast address (239.255.0.1) with the following code :
void send(void)
{
struct sockaddr_in addr;
int fd;
char *message="Hello, World!";
/* create an UDP socket */
if ((fd=socket(PF_INET,SOCK_DGRAM,0)) < 0) {
perror("socket");
exit(1);
}
/* set up destination address */
addr.sin_addr.s_addr=HTONL(0xefff0001);
addr.sin_port=HTONS(7400);
addr.sin_family=AF_INET;
/* now just sendto() our destination! */
while (1) {
if (sendto(fd,message,sizeof(message),0,(struct sockaddr *) &addr,
sizeof(addr)) < 0) {
perror("sendto");
exit(1);
}
sleep(1);
}
}
When I run it I got :
psock_udp_sendto: ERROR: udp_find_raddr_device failed
psock_sendto: ERROR: Family-specific send failed: -114
sendto: Error 114
Which make sense according to the code because "netdev_findby_ipv4addr" only check for broadcast IP and the multicast 239.255.0.1 don't matches with any netdevice in "netdev_finddevice_ipv4addr"...
What I'm missing ?
regards,
Louis
I'm trying to send some UDP packages with a multicast address (239.255.0.1) with the following code :
void send(void)
{
struct sockaddr_in addr;
int fd;
char *message="Hello, World!";
/* create an UDP socket */
if ((fd=socket(PF_INET,SOCK_DGRAM,0)) < 0) {
perror("socket");
exit(1);
}
/* set up destination address */
addr.sin_addr.s_addr=HTONL(0xefff0001);
addr.sin_port=HTONS(7400);
addr.sin_family=AF_INET;
/* now just sendto() our destination! */
while (1) {
if (sendto(fd,message,sizeof(message),0,(struct sockaddr *) &addr,
sizeof(addr)) < 0) {
perror("sendto");
exit(1);
}
sleep(1);
}
}
When I run it I got :
psock_udp_sendto: ERROR: udp_find_raddr_device failed
psock_sendto: ERROR: Family-specific send failed: -114
sendto: Error 114
Which make sense according to the code because "netdev_findby_ipv4addr" only check for broadcast IP and the multicast 239.255.0.1 don't matches with any netdevice in "netdev_finddevice_ipv4addr"...
What I'm missing ?
regards,
Louis