Changeset 7459 for code/trunk/src/libraries/network/ClientConnection.cc
- Timestamp:
- Sep 17, 2010, 12:48:29 AM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/ipv6 (added) merged: 7293-7295,7320,7322,7328-7330,7376-7378,7381-7382,7384-7387,7389-7394,7396-7397,7402,7411,7414,7433,7435,7437-7438,7442-7443,7453-7454
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/network/ClientConnection.cc
r7284 r7459 48 48 this->serverAddress_ = new ENetAddress(); 49 49 //set standard address and port 50 enet_address_set_host(this->serverAddress_, "127.0.0.1"); 50 enet_address_set_host(this->serverAddress_, "127.0.0.1"); // TODO: check for IPv6 and connect to ::1 instead 51 51 serverAddress_->port = NETWORK_PORT; 52 52 } … … 59 59 60 60 void ClientConnection::setServerAddress( const std::string& serverAddress ) { 61 enet_address_set_host (this->serverAddress_, serverAddress.c_str()); 61 if (enet_address_set_host (this->serverAddress_, serverAddress.c_str()) < 0) 62 COUT(1) << "Error: Could not resolve \"" << serverAddress << "\"." << std::endl; 62 63 } 63 64 … … 70 71 ENetEvent event; 71 72 72 this->host_ = enet_host_create(NULL, NETWORK_CLIENT_MAX_CONNECTIONS, 0, 0 );73 this->host_ = enet_host_create(NULL, NETWORK_CLIENT_MAX_CONNECTIONS, 0, 0, 0); 73 74 if ( this->host_ == NULL ) 74 75 { 75 COUT( 2) << "ClientConnection: host_ == NULL" << std::endl;76 COUT(1) << "ClientConnection: host_ == NULL" << std::endl; 76 77 // error handling 77 78 return false; 78 79 } 79 this->server_ = enet_host_connect(this->host_, serverAddress_, NETWORK_CLIENT_CHANNELS); 80 assert( this->host_->socket4 != ENET_SOCKET_NULL || this->host_->socket6 != ENET_SOCKET_NULL ); 81 if (this->host_->socket4 == ENET_SOCKET_NULL) 82 COUT(2) << "Warning: IPv4 Socket failed." << std::endl; 83 else if (this->host_->socket6 == ENET_SOCKET_NULL) 84 COUT(2) << "Warning: IPv6 Socket failed." << std::endl; 85 else 86 COUT(3) << "Info: Using IPv4 and IPv6 Sockets." << std::endl; 87 88 this->server_ = enet_host_connect(this->host_, serverAddress_, NETWORK_CLIENT_CHANNELS, 0); 80 89 if ( this->server_==NULL ) 81 90 { 82 COUT( 2) << "ClientConnection: server== NULL" << std::endl;91 COUT(1) << "ClientConnection: server_ == NULL" << std::endl; 83 92 // error handling 84 93 return false;
Note: See TracChangeset
for help on using the changeset viewer.