]> git.mxchange.org Git - simgear.git/blobdiff - simgear/io/sg_netChannel.cxx
Ensure individual log-level setting works.
[simgear.git] / simgear / io / sg_netChannel.cxx
index 86839e71a707384661f9a5555cdd1f7d38e3e0d2..817650ac482b04c5da9b835d3809e15530f65e8d 100644 (file)
@@ -16,7 +16,7 @@
  
      You should have received a copy of the GNU Library General Public
      License along with this library; if not, write to the Free Software
-     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA
  
      For further information visit http://plib.sourceforge.net
 
@@ -209,6 +209,13 @@ NetChannel::handleResolve()
         return 0; // not looked up yet, wait longer
     }
     
+    if (!addr.isValid()) {
+        SG_LOG(SG_IO, SG_WARN, "Network: host lookup failed:" << host);
+        handleError (ENOENT);
+        close();
+        return -1;
+    }
+    
     resolving_host = false;
     addr.setPort(port);
     int result = Socket::connect ( &addr ) ;
@@ -320,8 +327,13 @@ void NetChannel::handleAccept (void) {
   SG_LOG(SG_IO, SG_WARN, "Network:" << getHandle() << ": unhandled accept");
 }
 
-void NetChannel::handleError (int error) {
-  SG_LOG(SG_IO, SG_WARN,"Network:" << getHandle() << ": errno: " << strerror(errno) <<"(" << errno << ")");
+void NetChannel::handleError (int error)
+{
+    // warn about address lookup failures seperately, don't warn again.
+    // (and we (ab-)use ENOENT to mean 'name not found'.
+    if (error != ENOENT) {
+        SG_LOG(SG_IO, SG_WARN,"Network:" << getHandle() << ": errno: " << strerror(errno) <<"(" << errno << ")");
+    }
 }
 
 } // of namespace simgear