summaryrefslogtreecommitdiff
path: root/libs/midi++2
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2015-12-12 01:13:49 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2015-12-12 01:13:49 -0500
commite9e477ffe5d6db6795c535c854a9eac7c773ba71 (patch)
tree0a0c29a138449d96e6f07f2de6290a5a96c67b56 /libs/midi++2
parent6f7112547658b01594d8cd81a0f52c4edc017e1d (diff)
some attempted changes for ipMIDI on windows
Diffstat (limited to 'libs/midi++2')
-rw-r--r--libs/midi++2/ipmidi_port.cc24
1 files changed, 23 insertions, 1 deletions
diff --git a/libs/midi++2/ipmidi_port.cc b/libs/midi++2/ipmidi_port.cc
index 8e907471e0..cf4e6b243d 100644
--- a/libs/midi++2/ipmidi_port.cc
+++ b/libs/midi++2/ipmidi_port.cc
@@ -31,6 +31,7 @@
#endif
#if defined(PLATFORM_WINDOWS)
#include <winsock2.h>
+#include <ws2tcpip.h>
#else
#include <netdb.h>
#endif
@@ -111,6 +112,7 @@ IPMIDIPort::close_sockets ()
}
}
+#ifndef PLATFORM_WINDOWS
static bool
get_address (int sock, struct in_addr *inaddr, const string& ifname )
{
@@ -140,6 +142,7 @@ get_address (int sock, struct in_addr *inaddr, const string& ifname )
return true;
}
+#endif
bool
IPMIDIPort::open_sockets (int base_port, const string& ifname)
@@ -172,6 +175,7 @@ IPMIDIPort::open_sockets (int base_port, const string& ifname)
// INADDR_ANY will bind to default interface,
// specify alternate interface nameon which to bind...
struct in_addr if_addr_in;
+#ifndef PLATFORM_WINDOWS
if (!ifname.empty()) {
if (!get_address(sockin, &if_addr_in, ifname)) {
error << string_compose ("socket(in): could not find interface address for %1", ifname) << endmsg;
@@ -185,6 +189,9 @@ IPMIDIPort::open_sockets (int base_port, const string& ifname)
} else {
if_addr_in.s_addr = htonl (INADDR_ANY);
}
+#else
+ if_addr_in.s_addr = htonl (INADDR_ANY);
+#endif
struct ip_mreq mreq;
mreq.imr_multiaddr.s_addr = ::inet_addr("225.0.0.37");
@@ -229,6 +236,8 @@ IPMIDIPort::open_sockets (int base_port, const string& ifname)
return false;
}
+#ifndef PLATFORM_WINDOWS
+
if (fcntl (sockin, F_SETFL, O_NONBLOCK)) {
error << "cannot set non-blocking mode for IP MIDI input socket (" << ::strerror (errno) << ')' << endmsg;
return false;
@@ -239,6 +248,20 @@ IPMIDIPort::open_sockets (int base_port, const string& ifname)
return false;
}
+#else
+ // If iMode!=0, non-blocking mode is enabled.
+ u_long mode=1;
+ if (ioctlsocket(sockin,FIONBIO,&imode)) {
+ error << "cannot set non-blocking mode for IP MIDI input socket (" << ::strerror (errno) << ')' << endmsg;
+ return false;
+ }
+ imode = 1;
+ if (ioctlsocket(sockout,FIONBIO,&iMode)) {
+ error << "cannot set non-blocking mode for IP MIDI output socket (" << ::strerror (errno) << ')' << endmsg;
+ return false;
+ }
+#endif
+
return true;
}
@@ -287,4 +310,3 @@ IPMIDIPort::parse (framecnt_t timestamp)
::perror ("failed to recv from socket");
}
}
-