1
0
Fork 0

Set SO_REUSEADDR on incoming UDP socket so other processes on the host

can also monitor the UDP broadcasts.
This commit is contained in:
curt 2003-01-06 02:51:07 +00:00
parent e160b3b312
commit 7805202fc6

View file

@ -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 );