From 9ea7011bfb73471b1547ef2ad597196eda034f19 Mon Sep 17 00:00:00 2001 From: Chris Teubert Date: Mon, 1 Dec 2014 14:44:06 -0800 Subject: [PATCH] Fixed bug in xplaneConnect.c Fixed bug in openUDP where sockets could not be reopened in OS X --- C/src/xplaneConnect.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/C/src/xplaneConnect.c b/C/src/xplaneConnect.c index 873bee2..2ba2572 100644 --- a/C/src/xplaneConnect.c +++ b/C/src/xplaneConnect.c @@ -89,6 +89,7 @@ struct xpcSocket openUDP(unsigned short port_number, const char *xpIP, unsigned #if (__APPLE__ || __linux) struct timeval tv; + int optval = 1; #endif // Setup Port @@ -147,6 +148,10 @@ struct xpcSocket openUDP(unsigned short port_number, const char *xpIP, unsigned return theSocket; } + // Options + setsockopt(theSocket.sock, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)); + setsockopt(theSocket.sock, SOL_SOCKET, SO_REUSEPORT, &optval, sizeof(optval)); + //Bind if ( bind(theSocket.sock, (struct sockaddr *) &server, sizeof(server)) == -1) {