Changeset 7402 for code/branches/ipv6/src/libraries/network
- Timestamp:
- Sep 11, 2010, 2:31:39 AM (14 years ago)
- Location:
- code/branches/ipv6/src/libraries/network
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ipv6/src/libraries/network/ClientConnection.cc
r7294 r7402 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 … … 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 } 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 79 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; -
code/branches/ipv6/src/libraries/network/LANDiscoverable.cc
r7295 r7402 70 70 assert( this->host_ == 0 ); 71 71 this->host_ = enet_host_create( &bindAddress, 10, 0, 0, 0 ); 72 if ( this->host_ == NULL ) 73 COUT(1) << "LANDiscoverable: host_ == NULL" << std::endl; 72 74 } 73 75 else -
code/branches/ipv6/src/libraries/network/LANDiscovery.cc
r7322 r7402 43 43 { 44 44 this->host_ = enet_host_create(NULL, 10, 0, 0, 0 ); 45 if ( this->host_ == NULL ) 46 COUT(1) << "LANDiscovery: host_ == NULL" << std::endl; 45 47 } 46 48 … … 62 64 address.host = ENET_HOST_BROADCAST; 63 65 peer = enet_host_connect(this->host_, &address, 0, 0); 66 if (peer == NULL) 67 COUT(1) << "Error: Could not send LAN discovery to IPv4 Broadcast." << std::endl; 64 68 65 69 /* IPv6 */ 66 70 enet_address_set_host(&address, "ff02::1"); // TODO: use a multicast group 67 71 peer = enet_host_connect(this->host_, &address, 0, 0); 72 if (peer == NULL) 73 COUT(1) << "Error: Could not send LAN discovery to IPv6 Multicast." << std::endl; 68 74 69 75 ENetEvent event; -
code/branches/ipv6/src/libraries/network/ServerConnection.cc
r7295 r7402 56 56 57 57 void ServerConnection::setBindAddress( const std::string& bindAddress ) { 58 enet_address_set_host (this->bindAddress_, bindAddress.c_str()); 58 if (enet_address_set_host (this->bindAddress_, bindAddress.c_str()) < 0) 59 COUT(1) << "Error: Could not resolve \"" << bindAddress << "\"." << std::endl; 59 60 } 60 61 … … 66 67 this->host_ = enet_host_create(this->bindAddress_, NETWORK_MAX_CONNECTIONS, 0, 0, 0); 67 68 if ( this->host_ == NULL ) 68 return false; 69 { 70 COUT(1) << "ServerConnection: host_ == NULL" << std::endl; 71 return false; 72 } 73 assert( this->host_->socket4 != ENET_SOCKET_NULL || this->host_->socket6 != ENET_SOCKET_NULL ); 74 if (this->host_->socket4 == ENET_SOCKET_NULL) 75 COUT(2) << "Warning: IPv4 Socket failed." << std::endl; 76 else if (this->host_->socket6 == ENET_SOCKET_NULL) 77 COUT(2) << "Warning: IPv6 Socket failed." << std::endl; 69 78 else 70 return true; 79 COUT(3) << "Info: Using IPv4 and IPv6 Sockets." << std::endl; 80 81 return true; 71 82 } 72 83
Note: See TracChangeset
for help on using the changeset viewer.