Index: /code/branches/masterserver/src/libraries/network/WANDiscovery.cc
===================================================================
--- /code/branches/masterserver/src/libraries/network/WANDiscovery.cc	(revision 7650)
+++ /code/branches/masterserver/src/libraries/network/WANDiscovery.cc	(revision 7651)
@@ -62,25 +62,26 @@
 
   /* callback for the network reply poller */
+  /* WORK MARK WORK WORK */
   /* NOTE implement protocol-specific part here. */
-  int rhandler( char *addr, ENetEvent *ev )
+  int WANDiscovery::rhandler( char *addr, ENetEvent *ev )
   { 
     /* handle incoming data */
     /* if a list entry arrives add to list */
-    if( !strncmp( ev->packet->data, MSPROTO_SERVERLIST_ITEM,
+    if( !strncmp( (char*)ev->packet->data, MSPROTO_SERVERLIST_ITEM,
       MSPROTO_SERVERLIST_ITEM_LEN ) )
     { 
       /* create server structure from that item */
-      ServerInformation toadd;
+      packet::ServerInformation toadd;
 
       /* fill in data */
-      toadd->setName( std::string(ev->packet->data + 
+      toadd.setServerName( std::string((char*)ev->packet->data + 
         MSPROTO_SERVERLIST_ITEM_LEN) );
-      toadd->setIP( std::string(ev->packet->data + 
+      toadd.setServerIP( std::string((char*)ev->packet->data + 
         MSPROTO_SERVERLIST_ITEM_LEN) );
 
       /* add to list */
-      this->servers_.add( toadd );
+      this->servers_.push_back( toadd );
     }
-    else if( !strncmp( ev->packet->data, MSPROTO_SERVERLIST_END,
+    else if( !strncmp( (char*)ev->packet->data, MSPROTO_SERVERLIST_END,
       MSPROTO_SERVERLIST_END_LEN ) )
     { return 1; }
@@ -99,5 +100,5 @@
 
     /* deal with replies */
-    while( !msc.pollForReply( rhandler ) ) 
+    while( !msc.pollForReply( WANDiscovery::rhandler ) ) 
       /* nothing */;
 
Index: /code/branches/masterserver/src/libraries/network/WANDiscovery.h
===================================================================
--- /code/branches/masterserver/src/libraries/network/WANDiscovery.h	(revision 7650)
+++ /code/branches/masterserver/src/libraries/network/WANDiscovery.h	(revision 7651)
@@ -77,4 +77,6 @@
        */
       static WANDiscovery& getInstance() { return Singleton<WANDiscovery>::getInstance(); } // tolua_export
+    
+      int rhandler( char *addr, ENetEvent *ev );
       
     private:
Index: /code/branches/masterserver/src/libraries/network/packet/ServerInformation.h
===================================================================
--- /code/branches/masterserver/src/libraries/network/packet/ServerInformation.h	(revision 7650)
+++ /code/branches/masterserver/src/libraries/network/packet/ServerInformation.h	(revision 7651)
@@ -50,4 +50,5 @@
         std::string   getServerName() { return this->serverName_; }
         void          setServerName(std::string name) { this->serverName_ = name; }
+        void          setServerIP( std::string IP ) { this->serverIP_ = IP; }
         uint32_t      getServerRTT() { return this->serverRTT_; }
         
Index: /code/branches/masterserver/src/modules/masterserver/MasterServer.cc
===================================================================
--- /code/branches/masterserver/src/modules/masterserver/MasterServer.cc	(revision 7650)
+++ /code/branches/masterserver/src/modules/masterserver/MasterServer.cc	(revision 7651)
@@ -57,13 +57,4 @@
       << event->peer->address.port << "\n";
 
-    /* game server or client connection? */
-    /* -> decide in protocol */
-    /* game server */
-    /* add to game server list */
-    /*  */
-
-    /* client */
-    /* add to client list */
-
     /* store string form of address here */
     event->peer->data = addrconv; 
@@ -82,11 +73,17 @@
     }
 
-    /* output that the disconnect happened, to be removed at a later time. */
+    /* output that the disconnect happened */
     COUT(4) << (char*)event->peer->data << " disconnected.\n";
 
+    /* create string from peer data */
+    std::string name = std::string( (char*)event->peer->data );
+
     /* remove the server from the list it belongs to */
+    this->mainlist->delServerByName( name );
 
     /* Reset the peer's client information. */
     if( event->peer->data ) free( event->peer->data );
+
+    /* done */
     return 0;
   }
@@ -95,6 +92,7 @@
   int 
   MasterServer::eventData( ENetEvent *event )
-  { /* output what's in the packet (to be removed later) */
+  { /* validate packet */
     if( !event || !(event->packet) || !(event->peer) )
+      //|| !(event->packet->data) || !strlen(event->packet->data) )
     { COUT(2) << "No complete event given.\n";
       return -1;
@@ -110,5 +108,5 @@
       << event->packet->dataLength
       << " containing "
-      << event->packet->data
+      << (const char*)event->packet->data
       << " was received from "
       << addrconv 
@@ -116,4 +114,5 @@
       << event->channelID << "\n";
 
+    /*
     //[> send some packet back for testing <]
     //[> TESTING <]
@@ -131,16 +130,53 @@
 
     //[> /TESTING <]
+    */
 
     /* GAME SERVER OR CLIENT CONNECTION? */
-
-    /* Game server */
-    /* parse data */
-    /* start actions */
-    /* and send reply */
-
-    /* client */
-    /* parse data */
-    /* start actions */
-    /* and send reply */
+    if( !strncmp( (char *)event->packet->data, MSPROTO_GAME_SERVER, 
+      MSPROTO_GAME_SERVER_LEN ) )
+    { /* Game server */
+
+      if( !strncmp( (char *)event->packet->data 
+        + MSPROTO_GAME_SERVER_LEN+1, 
+        MSPROTO_REGISTER_SERVER, MSPROTO_REGISTER_SERVER_LEN ) )
+      { /* register new server */
+        mainlist->addServer( packet::ServerInformation( event ) );
+      }
+    }
+    else if( !strncmp( (char *)event->packet->data, MSPROTO_CLIENT, 
+      MSPROTO_CLIENT_LEN) )
+    { /* client */
+      
+      if( !strncmp( (char *)event->packet->data + MSPROTO_CLIENT_LEN+1,
+        MSPROTO_REQ_LIST ) )
+      { /* send server list */
+        
+        /* get an iterator */
+        std::list<packet::ServerInformation *>::iterator i;
+
+        /* loop through list elements */
+        for( i = serverlist.begin(); i != serverlist.end(); ++i ) 
+        {
+          /* WORK MARK */
+          /* send this particular server */
+          /* build reply string */
+          char *tosend = (char *)calloc( (*i)->getServerIP().length() + 1,1 );
+          snprintf( "%s %s", MSPROTO_SERVERLIST_ITEM, (*i)->getServerIP() );
+
+          /* create packet from it */
+          ENetPacket * reply = enet_packet_create( tosend,
+            strlen( tosend ) + 1, 
+            ENET_PACKET_FLAG_RELIABLE);
+
+          /* Send the reply to the peer over channel id 0. */
+          enet_peer_send( event->peer, 0, reply );
+
+          /* One could just use enet_host_service() instead. */
+          enet_host_flush( this->server );
+        } 
+      }
+    }
+    else
+    { /* bad message, don't do anything. */ } 
 
     /* delete addrconv */
Index: /code/branches/masterserver/src/modules/masterserver/MasterServer.h
===================================================================
--- /code/branches/masterserver/src/modules/masterserver/MasterServer.h	(revision 7650)
+++ /code/branches/masterserver/src/modules/masterserver/MasterServer.h	(revision 7651)
@@ -39,4 +39,5 @@
 #include <network/packet/Welcome.h>
 #include <util/Singleton.h>
+#include <network/MasterServerProtocol.h>
 
 /* my includes */
@@ -46,8 +47,4 @@
 /* c compatibility */
 #include <cstdio>
-
-#define ORX_MSERVER_PORT 1234
-#define ORX_MSERVER_MAXCONNS 32
-#define ORX_MSERVER_MAXCHANS 2
 
 namespace orxonox 
Index: /code/branches/masterserver/src/modules/masterserver/ServerList.h
===================================================================
--- /code/branches/masterserver/src/modules/masterserver/ServerList.h	(revision 7650)
+++ /code/branches/masterserver/src/modules/masterserver/ServerList.h	(revision 7651)
@@ -77,7 +77,7 @@
       void sortByPing();
 
-    private:
       /** the list of servers for internal storage */
       std::list<packet::ServerInformation *> serverlist;
+    private:
   };
 }
