Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7402 for code/branches


Ignore:
Timestamp:
Sep 11, 2010, 2:31:39 AM (14 years ago)
Author:
adrfried
Message:

add some error messages in orxonox network code

Location:
code/branches/ipv6/src/libraries/network
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ipv6/src/libraries/network/ClientConnection.cc

    r7294 r7402  
    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
     
    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    }
     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
    7988    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;
  • code/branches/ipv6/src/libraries/network/LANDiscoverable.cc

    r7295 r7402  
    7070      assert( this->host_ == 0 );
    7171      this->host_ = enet_host_create( &bindAddress, 10, 0, 0, 0 );
     72      if ( this->host_ == NULL )
     73          COUT(1) << "LANDiscoverable: host_ == NULL" << std::endl;
    7274    }
    7375    else
  • code/branches/ipv6/src/libraries/network/LANDiscovery.cc

    r7322 r7402  
    4343  {
    4444    this->host_ = enet_host_create(NULL, 10, 0, 0, 0 );
     45    if ( this->host_ == NULL )
     46        COUT(1) << "LANDiscovery: host_ == NULL" << std::endl;
    4547  }
    4648
     
    6264    address.host = ENET_HOST_BROADCAST;
    6365    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;
    6468
    6569    /* IPv6 */
    6670    enet_address_set_host(&address, "ff02::1"); // TODO: use a multicast group
    6771    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;
    6874
    6975    ENetEvent event;
  • code/branches/ipv6/src/libraries/network/ServerConnection.cc

    r7295 r7402  
    5656
    5757  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;
    5960  }
    6061
     
    6667    this->host_ = enet_host_create(this->bindAddress_, NETWORK_MAX_CONNECTIONS, 0, 0, 0);
    6768    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;
    6978    else
    70       return true;
     79        COUT(3) << "Info: Using IPv4 and IPv6 Sockets." << std::endl;
     80
     81    return true;
    7182  }
    7283
Note: See TracChangeset for help on using the changeset viewer.