Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 17, 2010, 12:48:29 AM (14 years ago)
Author:
adrfried
Message:

Merged ipv6 branch

Orxonox now includes a modified version of ENet 1.3.0

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/network/ClientConnection.cc

    r7284 r7459  
    4848    this->serverAddress_ = new ENetAddress();
    4949    //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
    5151    serverAddress_->port = NETWORK_PORT;
    5252  }
     
    5959
    6060  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;
    6263  }
    6364
     
    7071    ENetEvent event;
    7172
    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);
    7374    if ( this->host_ == NULL )
    7475    {
    75       COUT(2) << "ClientConnection: host_ == NULL" << std::endl;
     76      COUT(1) << "ClientConnection: host_ == NULL" << std::endl;
    7677      // error handling
    7778      return false;
    7879    }
    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);
    8089    if ( this->server_==NULL )
    8190    {
    82       COUT(2) << "ClientConnection: server == NULL" << std::endl;
     91      COUT(1) << "ClientConnection: server_ == NULL" << std::endl;
    8392      // error handling
    8493      return false;
Note: See TracChangeset for help on using the changeset viewer.