Index: /code/branches/masterserver/src/libraries/network/MasterServerComm.cc
===================================================================
--- /code/branches/masterserver/src/libraries/network/MasterServerComm.cc	(revision 7649)
+++ /code/branches/masterserver/src/libraries/network/MasterServerComm.cc	(revision 7650)
@@ -111,4 +111,5 @@
       /* address buffer */
       char *addrconv = NULL;
+      int retval = 0;
 
       /* check what type of event it is and react accordingly */
@@ -136,5 +137,5 @@
           /* call the supplied callback, if any. */
           if( (*callback) != NULL )
-            (*callback)( addrconv, &(this->event) );
+            retval = (*callback)( addrconv, &(this->event) );
 
           enet_packet_destroy( event.packet );
@@ -145,5 +146,5 @@
 
       /* event handled, return 0 */
-      return 0;
+      return retval;
     }
 
@@ -158,4 +159,23 @@
     ENetPacket * packet = enet_packet_create( data, 
         strlen( data ) + 1, 
+        ENET_PACKET_FLAG_RELIABLE);
+
+    /* Send the packet to the peer over channel id 0. */
+    enet_peer_send (this->peer, 0, packet);
+
+    /* One could just use enet_host_service() instead. */
+    enet_host_flush( this->client );
+    if( packet ) free( packet );
+
+    /* all done. */
+    return 0;
+  }
+
+  int MasterServerComm::sendRequest( std::string data )
+  {
+    /* send the data to the friend */
+    /* Create a reliable packet of size 7 containing "packet\0" */
+    ENetPacket * packet = enet_packet_create( data.c_str(), 
+        data.length() + 1, 
         ENET_PACKET_FLAG_RELIABLE);
 
Index: /code/branches/masterserver/src/libraries/network/MasterServerComm.h
===================================================================
--- /code/branches/masterserver/src/libraries/network/MasterServerComm.h	(revision 7649)
+++ /code/branches/masterserver/src/libraries/network/MasterServerComm.h	(revision 7650)
@@ -29,4 +29,5 @@
 #include <cstdlib>
 #include <cstdio>
+#include <string>
 #include <cstring>
 #include <enet/enet.h>
@@ -65,4 +66,12 @@
       int sendRequest( char *data );
 
+      /** \param data The data to be sent. 
+       * \return 0 for success, other for error. 
+       * 
+       * Send a request to the master server containing data specified in data
+       * (string version)
+       */
+      int sendRequest( std::string data );
+
       /** \param callback The callback function to call with data receivced.
        * \return 0 for success, other for error
Index: /code/branches/masterserver/src/libraries/network/MasterServerProtocol.h
===================================================================
--- /code/branches/masterserver/src/libraries/network/MasterServerProtocol.h	(revision 7650)
+++ /code/branches/masterserver/src/libraries/network/MasterServerProtocol.h	(revision 7650)
@@ -0,0 +1,70 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Sandro 'smerkli' Merkli
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef MASTER_SERVER_PROTO
+#define MASTER_SERVER_PROTO
+
+/* master server address (to be moved elsewhere later) */
+#define MS_ADDRESS "localhost"
+
+#define MSPROTO_CLIENT "CL"
+#define MSPROTO_CLIENT_LEN 2 
+
+#define MSPROTO_REQ_LIST "REQ:LIST"
+
+
+
+
+#define MSPROTO_GAME_SERVER "GS"
+#define MSPROTO_GAME_SERVER_LEN 2
+
+#define MSPROTO_REGISTER_SERVER "REG:SER"
+#define MSPROTO_REGISTER_SERVER_LEN 7
+
+#define MSPROTO_SERVERLIST_ITEM "SI"
+#define MSPROTO_SERVERLIST_ITEM_LEN 2
+#define MSPROTO_SERVERLIST_END "SL_END"
+#define MSPROTO_SERVERLIST_END_LEN 6
+
+
+
+
+
+
+#define ORX_MSERVER_PORT 1234
+#define MS_ADDRESS "localhost"
+
+
+
+#define ORX_MSERVER_MAXCONNS 32
+#define ORX_MSERVER_MAXCHANS 2
+
+
+
+
+#endif /* MASTER_SERVER_PROTO */
Index: /code/branches/masterserver/src/libraries/network/Server.cc
===================================================================
--- /code/branches/masterserver/src/libraries/network/Server.cc	(revision 7649)
+++ /code/branches/masterserver/src/libraries/network/Server.cc	(revision 7650)
@@ -105,12 +105,16 @@
     /* initialize it and see if it worked */
     if( msc.initialize() )
-      COUT(1) << "Error: could not initialize master server communications!\n";
+    { COUT(1) << "Error: could not initialize master server communications!\n";
+      return;
+    }
 
     /* connect and see if it worked */
     if( msc.connect( MS_ADDRESS, 1234 ) )
-      COUT(1) << "Error: could not connect to master server!\n";
-
-    /* TODO */
+    { COUT(1) << "Error: could not connect to master server!\n";
+      return;
+    }
+
     /* now send the master server some note we're here */
+    msc.sendRequest( MSPROTO_GAME_SERVER " " MSPROTO_REGISTER_SERVER );
   }
 
@@ -164,5 +168,5 @@
 
   /* TODO */
-  int replyhandler( char *addr, ENetEvent *ev )
+  int rephandler( char *addr, ENetEvent *ev )
   { 
     /* handle incoming data */
@@ -174,5 +178,5 @@
   void Server::helper_HandleMasterServerRequests()
   { 
-    this->msc.pollForReply( replyhandler ); 
+    this->msc.pollForReply( rephandler ); 
   }
 
Index: /code/branches/masterserver/src/libraries/network/Server.h
===================================================================
--- /code/branches/masterserver/src/libraries/network/Server.h	(revision 7649)
+++ /code/branches/masterserver/src/libraries/network/Server.h	(revision 7650)
@@ -39,7 +39,6 @@
 #include "LANDiscoverable.h"
 #include "MasterServerComm.h"
+#include "MasterServerProtocol.h"
 
-/* proto (move to central point soon) */ 
-#define MS_ADDRESS "localhost"
 
 namespace orxonox
@@ -57,5 +56,9 @@
     ~Server();
 
+    /* helpers */
     void helper_ConnectToMasterserver();
+    void helper_HandleMasterServerRequests();
+    int replyhandler( char *addr, ENetEvent *ev );
+
     void open();
     void close();
Index: /code/branches/masterserver/src/libraries/network/WANDiscovery.cc
===================================================================
--- /code/branches/masterserver/src/libraries/network/WANDiscovery.cc	(revision 7649)
+++ /code/branches/masterserver/src/libraries/network/WANDiscovery.cc	(revision 7650)
@@ -63,10 +63,26 @@
   /* callback for the network reply poller */
   /* NOTE implement protocol-specific part here. */
-  int replyhandler( char *addr, ENetEvent *ev )
+  int rhandler( char *addr, ENetEvent *ev )
   { 
-    /* handle incoming data
-     * if a list entry arrives add to list
-     * if a done entry arrives set done to true
-     */
+    /* handle incoming data */
+    /* if a list entry arrives add to list */
+    if( !strncmp( ev->packet->data, MSPROTO_SERVERLIST_ITEM,
+      MSPROTO_SERVERLIST_ITEM_LEN ) )
+    { 
+      /* create server structure from that item */
+      ServerInformation toadd;
+
+      /* fill in data */
+      toadd->setName( std::string(ev->packet->data + 
+        MSPROTO_SERVERLIST_ITEM_LEN) );
+      toadd->setIP( std::string(ev->packet->data + 
+        MSPROTO_SERVERLIST_ITEM_LEN) );
+
+      /* add to list */
+      this->servers_.add( toadd );
+    }
+    else if( !strncmp( ev->packet->data, MSPROTO_SERVERLIST_END,
+      MSPROTO_SERVERLIST_END_LEN ) )
+    { return 1; }
 
     /* done handling, return all ok code 0 */
@@ -80,8 +96,8 @@
 
     /* send request to server */
-    msc.sendRequest( MSPROTO_CLIENT MSPROTO_REQ_LIST );
+    msc.sendRequest( MSPROTO_CLIENT " " MSPROTO_REQ_LIST );
 
     /* deal with replies */
-    while( msc.pollForReply( replyhandler ) ) 
+    while( !msc.pollForReply( rhandler ) ) 
       /* nothing */;
 
Index: /code/branches/masterserver/src/libraries/network/WANDiscovery.h
===================================================================
--- /code/branches/masterserver/src/libraries/network/WANDiscovery.h	(revision 7649)
+++ /code/branches/masterserver/src/libraries/network/WANDiscovery.h	(revision 7650)
@@ -34,13 +34,8 @@
 #include "util/Singleton.h"
 #include "MasterServerComm.h"
+#include "MasterServerProtocol.h"
 
 #include <vector>
 
-/* master server address (to be moved elsewhere later) */
-#define MS_ADDRESS "localhost"
-
-/* protocol (to be moved elsewhere later) */
-#define MSPROTO_CLIENT "CL "
-#define MSPROTO_REQ_LIST "REQ:LIST"
 
 // tolua_begin
