#endif
struct ip_mreq mreq;
- mreq.imr_multiaddr.s_addr = ::inet_addr("225.0.0.37");
+ mreq.imr_multiaddr.s_addr = ::inet_addr("225.0.0.37"); /* ipMIDI group multicast address */
mreq.imr_interface.s_addr = if_addr_in.s_addr;
if(::setsockopt (sockin, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *) &mreq, sizeof(mreq)) < 0) {
::perror("setsockopt(IP_ADD_MEMBERSHIP)");
}
// Will Hall, Oct 2007
+#ifndef PLATFORM_WINDOWS
if (!ifname.empty()) {
struct in_addr if_addr_out;
if (!get_address(sockout, &if_addr_out, ifname)) {
return false;
}
}
+#endif
::memset(&addrout, 0, sizeof(struct sockaddr_in));
addrout.sin_family = AF_INET;
addrout.sin_addr.s_addr = ::inet_addr("225.0.0.37");
addrout.sin_port = htons (base_port);
+ struct sockaddr_in any;
+ ::memset(&any, 0, sizeof(struct sockaddr_in));
+ addrout.sin_family = AF_INET;
+ addrout.sin_addr.s_addr = INADDR_ANY;
+ addrout.sin_port = htons (base_port);
+
+ if (::bind(sockout, (struct sockaddr *) (&any), sizeof(any)) < 0) {
+ ::perror("bind");
+ cout << "ipmidi bind error\n";
+ return false;
+ }
+
+#ifndef PLATFORM_WINDOWS
+ int loop;
+ socklen_t size;
+#else
+ u_char loop;
+ int size;
+#endif
+
+ if (::getsockopt (sockout, 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...
- int loop = 0;
+ loop = 0;
if (::setsockopt(sockout, IPPROTO_IP, IP_MULTICAST_LOOP, (char *) &loop, sizeof (loop)) < 0) {
- ::perror("setsockopt(IP_MULTICAST_LOOP)");
+ //::perror("setsockopt(IP_MULTICAST_LOOP)");
+ cout << "Cannot set loopback status\n";
return false;
}
+ if (::getsockopt (sockout, 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)) {
}
#else
- // If iMode!=0, non-blocking mode is enabled.
+ // If imode !=0, non-blocking mode is enabled.
u_long mode=1;
- if (ioctlsocket(sockin,FIONBIO,&imode)) {
+ if (ioctlsocket(sockin,FIONBIO,&mode)) {
error << "cannot set non-blocking mode for IP MIDI input socket (" << ::strerror (errno) << ')' << endmsg;
return false;
}
- imode = 1;
- if (ioctlsocket(sockout,FIONBIO,&iMode)) {
+ mode = 1; /* just in case it was modified in the previous call */
+ if (ioctlsocket(sockout,FIONBIO,&mode)) {
error << "cannot set non-blocking mode for IP MIDI output socket (" << ::strerror (errno) << ')' << endmsg;
return false;
}
#endif
-
+ cout << "ipmidi ports setup!!!!!!!\n";
return true;
}