Index: code/trunk/src/libraries/network/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/network/CMakeLists.txt	(revision 7401)
+++ code/trunk/src/libraries/network/CMakeLists.txt	(revision 7459)
@@ -71,5 +71,6 @@
   LINK_LIBRARIES
     ${ZLIB_LIBRARY}
-    ${ENET_LIBRARY}
+    #${ENET_LIBRARY}
+    enet_orxonox
     ${Boost_THREAD_LIBRARY}
     util
Index: code/trunk/src/libraries/network/ClientConnection.cc
===================================================================
--- code/trunk/src/libraries/network/ClientConnection.cc	(revision 7401)
+++ code/trunk/src/libraries/network/ClientConnection.cc	(revision 7459)
@@ -48,5 +48,5 @@
     this->serverAddress_ = new ENetAddress();
     //set standard address and port
-    enet_address_set_host(this->serverAddress_, "127.0.0.1");
+    enet_address_set_host(this->serverAddress_, "127.0.0.1"); // TODO: check for IPv6 and connect to ::1 instead
     serverAddress_->port = NETWORK_PORT;
   }
@@ -59,5 +59,6 @@
 
   void ClientConnection::setServerAddress( const std::string& serverAddress ) {
-    enet_address_set_host (this->serverAddress_, serverAddress.c_str());
+    if (enet_address_set_host (this->serverAddress_, serverAddress.c_str()) < 0)
+        COUT(1) << "Error: Could not resolve \"" << serverAddress << "\"." << std::endl;
   }
 
@@ -70,15 +71,23 @@
     ENetEvent event;
 
-    this->host_ = enet_host_create(NULL, NETWORK_CLIENT_MAX_CONNECTIONS, 0, 0);
+    this->host_ = enet_host_create(NULL, NETWORK_CLIENT_MAX_CONNECTIONS, 0, 0, 0);
     if ( this->host_ == NULL )
     {
-      COUT(2) << "ClientConnection: host_ == NULL" << std::endl;
+      COUT(1) << "ClientConnection: host_ == NULL" << std::endl;
       // error handling
       return false;
     }
-    this->server_ = enet_host_connect(this->host_, serverAddress_, NETWORK_CLIENT_CHANNELS);
+    assert( this->host_->socket4 != ENET_SOCKET_NULL || this->host_->socket6 != ENET_SOCKET_NULL );
+    if (this->host_->socket4 == ENET_SOCKET_NULL)
+        COUT(2) << "Warning: IPv4 Socket failed." << std::endl;
+    else if (this->host_->socket6 == ENET_SOCKET_NULL)
+        COUT(2) << "Warning: IPv6 Socket failed." << std::endl;
+    else
+        COUT(3) << "Info: Using IPv4 and IPv6 Sockets." << std::endl;
+
+    this->server_ = enet_host_connect(this->host_, serverAddress_, NETWORK_CLIENT_CHANNELS, 0);
     if ( this->server_==NULL )
     {
-      COUT(2) << "ClientConnection: server == NULL" << std::endl;
+      COUT(1) << "ClientConnection: server_ == NULL" << std::endl;
       // error handling
       return false;
Index: code/trunk/src/libraries/network/ClientInformation.cc
===================================================================
--- code/trunk/src/libraries/network/ClientInformation.cc	(revision 7401)
+++ code/trunk/src/libraries/network/ClientInformation.cc	(revision 7459)
@@ -216,5 +216,5 @@
     ClientInformation *temp = head_;
     while(temp!=0){
-      if(temp->getPeer()->address.host==peer->address.host && temp->getPeer()->address.port==peer->address.port)
+      if(!memcmp(& temp->getPeer()->address, & peer->address, sizeof(peer->address)))
         break;
       temp = temp->next();
@@ -252,5 +252,5 @@
     ClientInformation *temp = head_;
     while(temp!=0){
-      if(temp->getPeer()->address.host==address->host && temp->getPeer()->address.port == address->port)
+      if(!memcmp(& temp->getPeer()->address, address, sizeof(*address)))
         break;
       temp = temp->next();
Index: code/trunk/src/libraries/network/LANDiscoverable.cc
===================================================================
--- code/trunk/src/libraries/network/LANDiscoverable.cc	(revision 7401)
+++ code/trunk/src/libraries/network/LANDiscoverable.cc	(revision 7459)
@@ -64,7 +64,12 @@
     if( bActive )
     {
-      ENetAddress bindAddress = { ENET_HOST_ANY, LAN_DISCOVERY_PORT };
+      ENetAddress bindAddress;
+      memset(& bindAddress, 0, sizeof(ENetAddress));
+      bindAddress.host = ENET_HOST_ANY;
+      bindAddress.port = LAN_DISCOVERY_PORT;
       assert( this->host_ == 0 );
-      this->host_ = enet_host_create( &bindAddress, 10, 0, 0 );
+      this->host_ = enet_host_create( &bindAddress, 10, 0, 0, 0 );
+      if ( this->host_ == NULL )
+          COUT(1) << "LANDiscoverable: host_ == NULL" << std::endl;
     }
     else
@@ -89,4 +94,6 @@
       {
         case ENET_EVENT_TYPE_CONNECT:
+            COUT(4) << "Received LAN discovery connect from client " << event.peer->host->receivedAddress << std::endl;
+            break;
         case ENET_EVENT_TYPE_DISCONNECT:
         case ENET_EVENT_TYPE_NONE:
@@ -95,4 +102,5 @@
           if( strcmp( LAN_DISCOVERY_MESSAGE, (char*)event.packet->data ) == 0 )      // check for a suitable orxonox client
           {
+            COUT(3) << "Received LAN discovery message from client " << event.peer->host->receivedAddress << std::endl;
             packet::ServerInformation info;
             info.setServerName("Orxonox Server");
Index: code/trunk/src/libraries/network/LANDiscovery.cc
===================================================================
--- code/trunk/src/libraries/network/LANDiscovery.cc	(revision 7401)
+++ code/trunk/src/libraries/network/LANDiscovery.cc	(revision 7459)
@@ -42,5 +42,7 @@
   LANDiscovery::LANDiscovery()
   {
-    this->host_ = enet_host_create(NULL, 10, 0, 0 );
+    this->host_ = enet_host_create(NULL, 10, 0, 0, 0 );
+    if ( this->host_ == NULL )
+        COUT(1) << "LANDiscovery: host_ == NULL" << std::endl;
   }
 
@@ -53,10 +55,21 @@
   {
     this->servers_.clear();
+    ENetPeer* peer;
     ENetAddress address;
-    enet_address_set_host(&address, "255.255.255.255");
+    memset(&address, 0, sizeof(ENetAddress));
     address.port = LAN_DISCOVERY_PORT;
 
-    ENetPeer* peer;
-    peer = enet_host_connect(this->host_, &address, 0);
+    /* TODO: check for availability of each protocol */
+    /* IPv4 */
+    address.host = ENET_HOST_BROADCAST;
+    peer = enet_host_connect(this->host_, &address, 0, 0);
+    if (peer == NULL)
+        COUT(1) << "Error: Could not send LAN discovery to IPv4 Broadcast." << std::endl;
+
+    /* IPv6 */
+    enet_address_set_host(&address, "ff02::1"); // TODO: use a multicast group
+    peer = enet_host_connect(this->host_, &address, 0, 0);
+    if (peer == NULL)
+        COUT(1) << "Error: Could not send LAN discovery to IPv6 Multicast." << std::endl;
 
     ENetEvent event;
@@ -67,5 +80,5 @@
         case ENET_EVENT_TYPE_CONNECT:
         {
-          COUT(0) << "connect from server: " << event.peer->address.host << endl;
+          COUT(4) << "Received LAN discovery connect from server " << event.peer->host->receivedAddress << std::endl;
           ENetPacket* packet = enet_packet_create(LAN_DISCOVERY_MESSAGE, strlen(LAN_DISCOVERY_MESSAGE)+1, ENET_PACKET_FLAG_RELIABLE);
           enet_peer_send(event.peer, 0, packet);
@@ -75,5 +88,5 @@
           {
             packet::ServerInformation info(&event);
-            COUT(0) << "received server information; name: " << info.getServerName() << ", IP: " << info.getServerIP() << ", RTT: " << info.getServerRTT() << endl;
+            COUT(3) << "Received LAN discovery server information; Name: " << info.getServerName() << ", Address: " << info.getServerIP() << ", RTT: " << info.getServerRTT() << endl;
             std::vector<packet::ServerInformation>::iterator it;
             for( it=this->servers_.begin(); it!=this->servers_.end(); ++it )
Index: code/trunk/src/libraries/network/ServerConnection.cc
===================================================================
--- code/trunk/src/libraries/network/ServerConnection.cc	(revision 7401)
+++ code/trunk/src/libraries/network/ServerConnection.cc	(revision 7459)
@@ -44,4 +44,5 @@
   {
     this->bindAddress_ = new ENetAddress();
+    memset(this->bindAddress_, 0, sizeof(ENetAddress));
     this->bindAddress_->host = ENET_HOST_ANY;
     this->bindAddress_->port = NETWORK_PORT;
@@ -55,5 +56,6 @@
 
   void ServerConnection::setBindAddress( const std::string& bindAddress ) {
-    enet_address_set_host (this->bindAddress_, bindAddress.c_str());
+    if (enet_address_set_host (this->bindAddress_, bindAddress.c_str()) < 0)
+        COUT(1) << "Error: Could not resolve \"" << bindAddress << "\"." << std::endl;
   }
 
@@ -63,9 +65,19 @@
 
   bool ServerConnection::openListener() {
-    this->host_ = enet_host_create(this->bindAddress_, NETWORK_MAX_CONNECTIONS, 0, 0);
+    this->host_ = enet_host_create(this->bindAddress_, NETWORK_MAX_CONNECTIONS, 0, 0, 0);
     if ( this->host_ == NULL )
-      return false;
+    {
+        COUT(1) << "ServerConnection: host_ == NULL" << std::endl;
+        return false;
+    }
+    assert( this->host_->socket4 != ENET_SOCKET_NULL || this->host_->socket6 != ENET_SOCKET_NULL );
+    if (this->host_->socket4 == ENET_SOCKET_NULL)
+        COUT(2) << "Warning: IPv4 Socket failed." << std::endl;
+    else if (this->host_->socket6 == ENET_SOCKET_NULL)
+        COUT(2) << "Warning: IPv6 Socket failed." << std::endl;
     else
-      return true;
+        COUT(3) << "Info: Using IPv4 and IPv6 Sockets." << std::endl;
+
+    return true;
   }
 
Index: code/trunk/src/libraries/network/packet/ServerInformation.cc
===================================================================
--- code/trunk/src/libraries/network/packet/ServerInformation.cc	(revision 7401)
+++ code/trunk/src/libraries/network/packet/ServerInformation.cc	(revision 7459)
@@ -47,9 +47,10 @@
     ServerInformation::ServerInformation(ENetEvent* event)
     {
+      char serverIP[64];
+
       // Save Server Round Trip Time
       this->serverRTT_ = event->peer->roundTripTime;
-      // Save Server IP
-      char* serverIP = new char[16];
-      enet_address_get_host_ip(&event->peer->address, serverIP, 16);
+      // Save Server Address, leave some space for scope ID
+      enet_address_get_host_ip(&event->peer->address, serverIP, 64);
       this->serverIP_ = std::string(serverIP);
       // Save ACK
@@ -83,4 +84,12 @@
   
   } // namespace packet
+
+  std::ostream& operator<<(std::ostream& out, const ENetAddress& address)
+  {
+      char addr[64];
+      if (!enet_address_get_host_ip(&address, addr, 64))
+          out << addr;
+      return out;
+  }
 } // namespace orxonox
 
Index: code/trunk/src/libraries/network/packet/ServerInformation.h
===================================================================
--- code/trunk/src/libraries/network/packet/ServerInformation.h	(revision 7401)
+++ code/trunk/src/libraries/network/packet/ServerInformation.h	(revision 7459)
@@ -59,4 +59,6 @@
 
   }
+
+  _NetworkExport std::ostream& operator<<(std::ostream& out, const ENetAddress& address);
 }
 
