X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FNetwork%2Fprops.cxx;h=58905e2f30a8a1c953cf05e017cac6d0239e0de4;hb=b0dcb657e77579ecc79798ff365737095f96f9e2;hp=8ea9596c52cba3e6daa1793eca8d41023cd199c0;hpb=9b4c2def75605908e81becfd0fab0a2ae70a3629;p=flightgear.git diff --git a/src/Network/props.cxx b/src/Network/props.cxx index 8ea9596c5..58905e2f3 100644 --- a/src/Network/props.cxx +++ b/src/Network/props.cxx @@ -185,7 +185,7 @@ void PropsChannel::unsubscribe(const ParameterList ¶m) { SGPropertyNode *n = globals->get_props()->getNode( param[1].c_str() ); if (n) n->removeChangeListener( this ); - } catch (sg_exception &e) { + } catch (sg_exception&) { error("Error:Listener could not be removed"); } } @@ -552,7 +552,6 @@ FGProps::FGProps( const vector& tokens ) } else { throw FGProtocolConfigError( "FGProps: incorrect number of configuration arguments" ); } - printf( "Property server started on port %d\n", port ); } /** @@ -575,9 +574,28 @@ FGProps::open() return false; } - simgear::NetChannel::open(); - simgear::NetChannel::bind( "", port ); - simgear::NetChannel::listen( 5 ); + if (!simgear::NetChannel::open()) + { + SG_LOG( SG_IO, SG_ALERT, "FGProps: Failed to open network socket."); + return false; + } + + int err = simgear::NetChannel::bind( "", port ); + if (err) + { + SG_LOG( SG_IO, SG_ALERT, "FGProps: Failed to open port #" << port << " - the port is already used (error " << err << ")."); + return false; + } + + err = simgear::NetChannel::listen( 5 ); + if (err) + { + SG_LOG( SG_IO, SG_ALERT, "FGProps: Failed to listen on port #" << port << "(error " << err << ")."); + return false; + } + + poller.addChannel(this); + SG_LOG( SG_IO, SG_INFO, "Props server started on port " << port ); set_enabled( true ); @@ -600,7 +618,7 @@ FGProps::close() bool FGProps::process() { - simgear::NetChannel::poll(); + poller.poll(); return true; } @@ -616,4 +634,5 @@ FGProps::handleAccept() << addr.getHost() << ":" << addr.getPort() ); PropsChannel* channel = new PropsChannel(); channel->setHandle( handle ); + poller.addChannel( channel ); }