Index: code/branches/presentation/src/libraries/network/MasterServer.cc
===================================================================
--- code/branches/presentation/src/libraries/network/MasterServer.cc	(revision 7750)
+++ code/branches/presentation/src/libraries/network/MasterServer.cc	(revision 7756)
@@ -185,4 +185,6 @@
           packet::ServerInformation( event ).getServerIP() << "\n";
       }
+
+      /* TODO add hook for disconnect here */
     }
     else if( !strncmp( (char *)event->packet->data, MSPROTO_CLIENT, 
@@ -218,4 +220,5 @@
     }
 
+    /* TODO schedule pings for servers somewhere here */
     
     /* create an iterator for the loop */
Index: code/branches/presentation/src/libraries/network/MasterServerComm.cc
===================================================================
--- code/branches/presentation/src/libraries/network/MasterServerComm.cc	(revision 7750)
+++ code/branches/presentation/src/libraries/network/MasterServerComm.cc	(revision 7756)
@@ -38,5 +38,4 @@
   } 
 
-
   int MasterServerComm::initialize()
   {
@@ -52,5 +51,4 @@
     /* install atexit handler for enet */
     atexit( enet_deinitialize );
-
 
     /* initiate the client */
@@ -87,5 +85,5 @@
     if (this->peer == NULL )
     { COUT(2) << "ERROR: No available peers for initiating an ENet connection.\n";
-    return -1;
+      return -1;
     }
 
@@ -102,8 +100,16 @@
     }
 
-    return 0;
-  }
-
-  int MasterServerComm::pollForReply( int (*callback)( char*, ENetEvent* ) )
+    /* all fine */
+    return 0;
+  }
+
+  /* NOTE this is to be reimplemented soon to return 
+   * a structure containing 
+   * - addrconv
+   * - the event
+   * so we can also make callbacks from objects
+   */
+  int MasterServerComm::pollForReply( int (*callback)( char*, ENetEvent* ),
+    int delayms )
   { 
     /* see whether anything happened */
@@ -117,5 +123,5 @@
     /* enet_host_service returns 0 if no event occured */
     /* just newly set below test to >0 from >= 0, to be tested */
-    if( enet_host_service( this->client, this->event, 1000 ) > 0 )
+    if( enet_host_service( this->client, this->event, delayms ) > 0 )
     { 
       /* check what type of event it is and react accordingly */
@@ -140,14 +146,9 @@
 
           /* DEBUG */
-          COUT(3) << "A packet of length " << this->event->packet->dataLength 
+          COUT(3) << "MasterServer Debug: A packet of length " 
+            << this->event->packet->dataLength 
             << " containing " << this->event->packet->data
             << " was received from " << addrconv 
             << " on channel " << this->event->channelID;
-          //printf( "A packet of length %u containing %s was "
-            //"received from %s on channel %u.\n",
-            //this->event->packet->dataLength,
-            //this->event->packet->data,
-            //addrconv,
-            //this->event->channelID );
           /* END DEBUG */
 
@@ -156,6 +157,9 @@
             retval = (*callback)( addrconv, (this->event) );
 
+          /* clean up */
           enet_packet_destroy( event->packet );
-          if( addrconv ) free( addrconv );
+          if( addrconv ) 
+            free( addrconv );
+
           break;
         default: break;
@@ -211,42 +215,2 @@
 
 }
-
-
-/* DON'T DELETE THIS I MIGHT NEED IT AGAIN -smerkli */
-/* not needed anymore, only here for testing purposes */
-/*
-//[> sample callback to output debugging info. <]
-//int callb( char *addr, ENetEvent *ev )
-//{ 
-  //printf( "A packet of length %u containing %s was "
-      //"received from %s on channel %u.\n",
-      //ev->packet->dataLength,
-      //ev->packet->data,
-      //addr,
-      //ev->channelID );
-  //return 0;
-//}
-
-//[> small testing implementation <]
-//int
-//main( int argc, char *argv[] )
-//{
-  //[> setup object and connect <]
-  //MasterServerComm msc = MasterServerComm();
-  //if( msc.connect( argv[1], 1234 ) )
-    //exit(EXIT_FAILURE);
-  
-  //[> send some data and poll for replies <]
-  //char *theinput = (char *)calloc( 100,1 );
-  //while( true )
-  //{ 
-    //fgets( theinput, 90, stdin );
-    //if( !strncmp( theinput, "quit", 4 ) )
-      //break;
-
-    //msc.sendRequest( theinput );
-    //msc.pollForReply( &callb );
-  //}
-
-//}
-*/
Index: code/branches/presentation/src/libraries/network/MasterServerComm.h
===================================================================
--- code/branches/presentation/src/libraries/network/MasterServerComm.h	(revision 7750)
+++ code/branches/presentation/src/libraries/network/MasterServerComm.h	(revision 7756)
@@ -81,5 +81,5 @@
        * 
        * Poll the master server for new data and act accordingly */
-      int pollForReply( int (*callback)( char*, ENetEvent* ) );
+      int pollForReply( int (*callback)( char*, ENetEvent* ), int delayms );
 
     private:
Index: code/branches/presentation/src/libraries/network/MasterServerProtocol.h
===================================================================
--- code/branches/presentation/src/libraries/network/MasterServerProtocol.h	(revision 7750)
+++ code/branches/presentation/src/libraries/network/MasterServerProtocol.h	(revision 7756)
@@ -33,4 +33,6 @@
 #define MS_ADDRESS "129.132.3.8"
 
+
+/*** CLIENT COMMUNICATIONS ***/
 /* Client token (shows that the party sending data is a client */
 #define MSPROTO_CLIENT "CL"
@@ -44,4 +46,5 @@
 
 
+/*** GAME SERVER COMMUNICATIONS ***/
 /* Game server token (shows that the party sending data is a game server) */
 #define MSPROTO_GAME_SERVER "GS"
@@ -62,4 +65,12 @@
 #define MSPROTO_SERVERLIST_END_LEN 6
 
+/* ping request from server */
+#define MSPROTO_PING_GAMESERVER "PING"
+#define MSPROTO_PING_GAMESERVER_LEN 4 
+
+/* ping reply */
+#define MSPROTO_ACK "ACK"
+#define MSPROTO_ACK_LEN 3 
+
 
 
Index: code/branches/presentation/src/libraries/network/Server.cc
===================================================================
--- code/branches/presentation/src/libraries/network/Server.cc	(revision 7750)
+++ code/branches/presentation/src/libraries/network/Server.cc	(revision 7756)
@@ -134,4 +134,7 @@
 
     /* make discoverable on WAN */
+    /* TODO this needs to be optional, we need a switch from the UI to
+     * enable/disable this 
+     */
     helper_ConnectToMasterserver();
 
@@ -169,9 +172,15 @@
 
 
-  /* TODO */
+  /* handle incoming data */
   int rephandler( char *addr, ENetEvent *ev )
   { 
-    /* handle incoming data */
-    /* TODO this is to be implemented. */
+    /* reply to pings */
+    if( !strncmp( (char *)ev->packet->data, MSPROTO_PING_GAMESERVER, 
+      MSPROTO_PING_GAMESERVER_LEN ) )
+      //this->msc.sendRequest( MSPROTO_ACK );
+      /* NOTE implement this after pollForReply
+       * reimplementation 
+       */
+      return 0;
 
     /* done handling, return all ok code 0 */
@@ -184,5 +193,5 @@
      * has to be done or changed.
      */
-    this->msc.pollForReply( rephandler ); 
+    this->msc.pollForReply( rephandler, 10 ); 
   }
 
Index: code/branches/presentation/src/libraries/network/WANDiscovery.cc
===================================================================
--- code/branches/presentation/src/libraries/network/WANDiscovery.cc	(revision 7750)
+++ code/branches/presentation/src/libraries/network/WANDiscovery.cc	(revision 7756)
@@ -133,5 +133,5 @@
     {
       /* poll for reply and act according to what was received */
-      switch( this->msc.pollForReply( rhandler ) )
+      switch( this->msc.pollForReply( rhandler, 1000 ) )
       { case 0: /* no event occured, decrease timeout */
           --i; break;
