HAL_SITL: fixed multicast UDP on cygwin

this will allow the SITL button on cygwin to work with multicast,
allowing for complex vehicle interactions between machines
This commit is contained in:
Andrew Tridgell 2023-06-21 15:22:32 +10:00
parent 0bad9451d5
commit 3bcceb9420
1 changed files with 8 additions and 0 deletions

View File

@ -568,6 +568,14 @@ void UARTDriver::_udp_start_multicast(const char *address, uint16_t port)
// close on exec, to allow reboot
fcntl(_mc_fd, F_SETFD, FD_CLOEXEC);
#if defined(__CYGWIN__) || defined(__CYGWIN64__) || defined(CYGWIN_BUILD)
/*
on cygwin you need to bind to INADDR_ANY then use the multicast
IP_ADD_MEMBERSHIP to get on the right address
*/
sockaddr.sin_addr.s_addr = htonl(INADDR_ANY);
#endif
ret = bind(_mc_fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr));
if (ret == -1) {
fprintf(stderr, "multicast bind failed on port %u - %s\n",