Sample Header Ad - 728x90

UDP multicast fails with "network unreachable" after static IP change on Linux 4.1

1 vote
0 answers
105 views
We have a requirement for UDP multicasting in our project using Linux 4.1 kernel with static ip address. Basic UDP multicasting by the use of the sendto function to send data works fine with device static ip 10.13.204.100; the issue comes when I change the ip address of the device to 10.13.204.101 or to any other ip in the same series, the udp multicasting starts showing the error: sendto: network unreachable The UDP has been initialized by the following function: int udp_init() { char multicastTTL = 10; // Create UDP socket: memset(&socket_desc, 0, sizeof(socket_desc)); socket_desc = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (socket_desc %d\nsocket_desc==>%d\n", udp_socket_fd, socket_desc); /* Set the TTL (time to live/hop count) for the send */ // if (setsockopt(socket_desc, IPPROTO_IP, IP_MULTICAST_TTL, &multicastTTL, sizeof(multicastTTL)) %s:%d\n", __FILE__, __FUNCTION__, __LINE__); return 1; } } Once the ip has been changed, the UDP socket is closed by the instruction: close(socket_desc) Once again the udp_init function (showed above) is used to initialize the UDP socket and then it is used the sendto function to transmit the data but this causes the error:
sendto:network unreachable
thanks in advance
Asked by Rajesh (23 rep)
Jan 4, 2023, 10:11 AM
Last activity: Apr 24, 2025, 12:17 PM