From: curt Date: Mon, 6 Jan 2003 02:51:07 +0000 (+0000) Subject: Set SO_REUSEADDR on incoming UDP socket so other processes on the host X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7805202fc67bf73c8d73667c723e16d49b77df07;p=flightgear.git Set SO_REUSEADDR on incoming UDP socket so other processes on the host can also monitor the UDP broadcasts. --- diff --git a/src/FDM/ExternalNet/ExternalNet.cxx b/src/FDM/ExternalNet/ExternalNet.cxx index d8b184bf2..a18b316f4 100644 --- a/src/FDM/ExternalNet/ExternalNet.cxx +++ b/src/FDM/ExternalNet/ExternalNet.cxx @@ -35,6 +35,10 @@ # include // htonl() ntohl() #endif +#if defined( linux ) +# include +# include +#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 );