X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fio%2Fsg_netChannel.cxx;h=c65025652b5181bab89456e882ac32b3bd49d6f8;hb=f18a9493b3a067ae56cb350cd6a390649ba6b35d;hp=d34a521bd465c4e6792ab56af0f097d84d33c092;hpb=878b504f8e044bc0e59903caa8641492421b76d8;p=simgear.git diff --git a/simgear/io/sg_netChannel.cxx b/simgear/io/sg_netChannel.cxx index d34a521b..c6502565 100644 --- a/simgear/io/sg_netChannel.cxx +++ b/simgear/io/sg_netChannel.cxx @@ -36,7 +36,6 @@ #include #include -#include namespace simgear { @@ -107,11 +106,21 @@ NetChannel::listen ( int backlog ) } int -NetChannel::connect ( const char* host, int p ) +NetChannel::connect ( const char* host, int port ) { - host_lookup = HostLookup::lookup(host); - port = p; - return 0; + int result = Socket::connect ( host, port ) ; + if (result == 0) { + connected = true ; + //this->handleConnect(); + return 0; + } else if (isNonBlockingError ()) { + return 0; + } else { + // some other error condition + this->handleError (result); + close(); + return -1; + } } int @@ -202,25 +211,6 @@ NetChannel::handleWriteEvent (void) this->handleWrite(); } -void -NetChannel::doConnect() -{ - IPAddress addr( host_lookup->address() ); - addr.setPort(port); - int result = Socket::connect ( addr ) ; - host_lookup = NULL; - - if (result == 0) { - connected = true ; - } else if (isNonBlockingError ()) { - - } else { - // some other error condition - handleError (result); - close(); - } -} - bool NetChannel::poll (unsigned int timeout) { @@ -246,16 +236,6 @@ NetChannel::poll (unsigned int timeout) else if ( ! ch -> closed ) { nopen++ ; - if (ch->host_lookup) { - if (ch->host_lookup->resolved()) { - ch->doConnect(); - } else if (ch->host_lookup->failed()) { - ch->handleError (-1); - ch->close(); - } - continue; - } - if (ch -> readable()) { assert(nreads