X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fmidi%2B%2B2%2Fipmidi_port.cc;h=fd5cb9a2395e727a457dda57104038439ea0429b;hb=466141229f0402c807902f9fc42446bd4416c600;hp=848276b220e9e420b677a7f6fb32cc59dceb7f5d;hpb=b520db4687f35692c071f6b2c37473280fb81f90;p=ardour.git diff --git a/libs/midi++2/ipmidi_port.cc b/libs/midi++2/ipmidi_port.cc index 848276b220..fd5cb9a239 100644 --- a/libs/midi++2/ipmidi_port.cc +++ b/libs/midi++2/ipmidi_port.cc @@ -231,36 +231,43 @@ IPMIDIPort::open_sockets (int base_port, const string& ifname) addrout.sin_addr.s_addr = ::inet_addr("225.0.0.37"); addrout.sin_port = htons (base_port); -#ifndef PLATFORM_WINDOWS - int loop; - socklen_t size; + // Turn off loopback... + int loop = 0; + +#ifdef PLATFORM_WINDOWS + + /* https://msdn.microsoft.com/en-us/library/windows/desktop/ms739161%28v=vs.85%29.aspx + * + * ------------------------------------------------------------------------------ + * Note The Winsock version of the IP_MULTICAST_LOOP option is + * semantically different than the UNIX version of the + * IP_MULTICAST_LOOP option: + * + * In Winsock, the IP_MULTICAST_LOOP option applies only to the receive path. + * In the UNIX version, the IP_MULTICAST_LOOP option applies to the send path. + * + * For example, applications ON and OFF (which are easier to track than + * X and Y) join the same group on the same interface; application ON + * sets the IP_MULTICAST_LOOP option on, application OFF sets the + * IP_MULTICAST_LOOP option off. If ON and OFF are Winsock + * applications, OFF can send to ON, but ON cannot sent to OFF. In + * contrast, if ON and OFF are UNIX applications, ON can send to OFF, + * but OFF cannot send to ON. + * ------------------------------------------------------------------------------ + * + * Alles klar? Gut! + */ + + const int target_sock = sockin; #else - u_char loop; - int size; + const int target_sock = sockout; #endif - if (::getsockopt (sockin, IPPROTO_IP, IP_MULTICAST_LOOP, (char *) &loop, &size)) { - // ::perror ("getsockopt(IP_MULTICAST_LOOP)"); - cout << "Cannot get loopback status\n"; - } else { - cout << "********* 1. multicast loopback: " << loop << " size was " << size << endl; - } - - // Turn off loopback... - loop = 0; - if (::setsockopt(sockout, IPPROTO_IP, IP_MULTICAST_LOOP, (char *) &loop, sizeof (loop)) < 0) { - //::perror("setsockopt(IP_MULTICAST_LOOP)"); - cout << "Cannot set loopback status\n"; + if (::setsockopt (target_sock, IPPROTO_IP, IP_MULTICAST_LOOP, (char *) &loop, sizeof (loop)) < 0) { + ::perror("setsockopt(IP_MULTICAST_LOOP)"); return false; } - if (::getsockopt (sockin, IPPROTO_IP, IP_MULTICAST_LOOP, (char *) &loop, &size)) { - // ::perror ("getsockopt(IP_MULTICAST_LOOP)"); - cout << "Cannot Get loopback status 2\n"; - } else { - cout << "********* 2. multicast loopback: " << loop << " size was " << size << endl; - } - #ifndef PLATFORM_WINDOWS if (fcntl (sockin, F_SETFL, O_NONBLOCK)) { @@ -286,7 +293,7 @@ IPMIDIPort::open_sockets (int base_port, const string& ifname) return false; } #endif - cout << "ipmidi ports setup!!!!!!!\n"; + return true; }