From 9968888e45f1c7287034f86b9c4b902d36946a74 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Fri, 21 Sep 2012 13:26:05 +0200 Subject: [PATCH] FGProps: improve error messages Lowlevel "simgear:NetChannel" only returns status infos, but doesn't output log messages itself. --- src/Network/props.cxx | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/Network/props.cxx b/src/Network/props.cxx index 8ea9596c5..436c2af73 100644 --- a/src/Network/props.cxx +++ b/src/Network/props.cxx @@ -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,26 @@ 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; + } + SG_LOG( SG_IO, SG_INFO, "Props server started on port " << port ); set_enabled( true ); -- 2.39.5