Set SO_REUSEADDR on incoming UDP socket so other processes on the host
can also monitor the UDP broadcasts.
This commit is contained in:
parent
e160b3b312
commit
7805202fc6
1 changed files with 13 additions and 0 deletions
|
@ -35,6 +35,10 @@
|
|||
# include <netinet/in.h> // htonl() ntohl()
|
||||
#endif
|
||||
|
||||
#if defined( linux )
|
||||
# include <sys/types.h>
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
// The function htond is defined this way due to the way some
|
||||
// processors and OSes treat floating point values. Some will raise
|
||||
|
@ -370,6 +374,15 @@ FGExternalNet::FGExternalNet( double dt, string host, int dop, int dip, int cp )
|
|||
// disable blocking
|
||||
data_server.setBlocking( false );
|
||||
|
||||
#if defined( linux )
|
||||
// set SO_REUSEADDR flag
|
||||
int socket = data_server.getHandle();
|
||||
int one = 1;
|
||||
int result;
|
||||
result = ::setsockopt( socket, SOL_SOCKET, SO_REUSEADDR,
|
||||
&one, sizeof(one) );
|
||||
#endif
|
||||
|
||||
// allowed to read from a broadcast addr
|
||||
// data_server.setBroadcast( true );
|
||||
|
||||
|
|
Loading…
Reference in a new issue