Index: code/branches/masterserver/src/modules/masterserver/MasterServer.cpp
===================================================================
--- code/branches/masterserver/src/modules/masterserver/MasterServer.cpp	(revision 7580)
+++ code/branches/masterserver/src/modules/masterserver/MasterServer.cpp	(revision 7589)
@@ -33,5 +33,7 @@
 /***** EVENTS *****/
 /* connect event */
-int eventConnect( ENetEvent *event )
+int eventConnect( ENetEvent *event, 
+  orxonox::ServerList *serverlist,
+  orxonox::PeerList *peers )
 { /* check for bad parameters */
   if( !event )
@@ -41,11 +43,14 @@
 
   /* output debug info */
-  //printf( "A new client connected from %x:%u.\n", 
-      //event->peer->address.host,
-      //event->peer->address.port);
+  printf( "A new client connected from %x:%u.\n", 
+      event->peer->address.host,
+      event->peer->address.port);
 
   /* game server or client connection? */
+  /* -> decide in protocol */
     /* game server */
       /* add to game server list */
+      /*  */
+
     /* client */
       /* add to client list */
@@ -61,5 +66,7 @@
 
 /* disconnect event */
-int eventDisconnect( ENetEvent *event )
+int eventDisconnect( ENetEvent *event,
+  orxonox::ServerList *serverlist,
+  orxonox::PeerList *peers )
 { /* check for bad parameters */
   if( !event )
@@ -69,5 +76,5 @@
 
   /* output that the disconnect happened, to be removed at a later time. */
-  //printf ("%s disconnected.\n", event->peer -> data);
+  printf( "%s disconnected.\n", event->peer->data );
 
   /* remove the server from the list it belongs to */
@@ -126,17 +133,12 @@
   ENetHost *server;
 
-  /* Bind the server to the default localhost.     */
-  /* A specific host address can be specified by   */
-  /* enet_address_set_host (& address, "x.x.x.x"); */
+  /* Bind the server to the default localhost and port ORX_MSERVER_PORT */
   address.host = ENET_HOST_ANY;
-
-  /* Bind the server to port 1234. */
   address.port = ORX_MSERVER_PORT;
 
-  server = enet_host_create( & address /* the address to bind the server host to */, 
-      ORX_MSERVER_MAXCONNS      /* allow up to 32 clients and/or outgoing connections */,
-      ORX_MSERVER_MAXCHANS      /* allow up to 2 channels to be used, 0 and 1 */,
-      0      /* assume any amount of incoming bandwidth */,
-      0      /* assume any amount of outgoing bandwidth */);
+  /* create a host with the above settings (the last two 0 mean: accept 
+   * any input/output bandwidth */
+  server = enet_host_create( &address, ORX_MSERVER_MAXCONNS, 
+    ORX_MSERVER_MAXCHANS, 0, 0 );     
 
   /* see if creation worked */
@@ -149,8 +151,11 @@
   /***** INITIALIZE GAME SERVER LIST *****/
   orxonox::ServerList *mainlist = new orxonox::ServerList();
-  //if( mainlist == NULL )
-  //{ fprintf( stderr, "Error creating server list.\n" );
-    //exit( EXIT_FAILURE );
-  //}
+  if( mainlist == NULL )
+  { fprintf( stderr, "Error creating server list.\n" );
+    exit( EXIT_FAILURE );
+  }
+
+  /***** INITIALIZE PEER LIST *****/
+  orxonox::PeerList *peers = new orxonox::PeerList();
 
   /***** ENTER MAIN LOOP *****/
@@ -161,20 +166,19 @@
   }
 
-  /* NOTE this only waits on one client, we need to find some way to 
-   * actually listen on all active connections. This will be implemented 
-   * together with the list of active connections.
-   */
-  /* Wait up to 1000 milliseconds for an event. */
-  while (enet_host_service (client, event, 1000) > 0)
+  /* create an iterator for the loop */
+  while( enet_host_service( server, event, 1000 ) > 0 )
   { /* check what type of event it is and react accordingly */
-    switch (event.type)
+    switch (event->type)
     { /* new connection */
-      case ENET_EVENT_TYPE_CONNECT: eventConnect( event ); break;
+      case ENET_EVENT_TYPE_CONNECT: 
+        eventConnect( event, mainlist, peers ); break;
 
       /* disconnect */
-      case ENET_EVENT_TYPE_DISCONNECT: eventDisconnect( event ); break;
+      case ENET_EVENT_TYPE_DISCONNECT: 
+        eventDisconnect( event, mainlist, peers ); break;
 
       /* incoming data */
       case ENET_EVENT_TYPE_RECEIVE: eventData( event ); break;
+      default: break;
     }
   }
Index: code/branches/masterserver/src/modules/masterserver/MasterServer.h
===================================================================
--- code/branches/masterserver/src/modules/masterserver/MasterServer.h	(revision 7580)
+++ code/branches/masterserver/src/modules/masterserver/MasterServer.h	(revision 7589)
@@ -41,4 +41,5 @@
 /* my includes */
 #include "ServerList.h"
+#include "PeerList.h"
 
 /* c compatibility */
Index: code/branches/masterserver/src/modules/masterserver/PeerList.h
===================================================================
--- code/branches/masterserver/src/modules/masterserver/PeerList.h	(revision 7580)
+++ code/branches/masterserver/src/modules/masterserver/PeerList.h	(revision 7589)
@@ -67,7 +67,13 @@
       ENetPeer *findPeerByAddr( ENetAddress addr );
 
+      /* NOTE: making this list public so it can easily 
+       * be iterated. This makes sense since iterating it
+       * will happen all the time, and using getter methods
+       * for the next in list would slow things down unnecessarily.
+       */
+      /** the list of servers for internal storage */
+      std::list<ENetPeer *> peerlist;
     private:
-      /** the list of servers for internal storage */
-      std::list<packet::ENetPeer *> peerlist;
+      /* nothing so far. */
   };
 }
Index: code/branches/masterserver/src/modules/masterserver/ServerList.cpp
===================================================================
--- code/branches/masterserver/src/modules/masterserver/ServerList.cpp	(revision 7580)
+++ code/branches/masterserver/src/modules/masterserver/ServerList.cpp	(revision 7589)
@@ -27,5 +27,5 @@
  */
 
- #include "ServerList.h"
+#include "ServerList.h"
 
 namespace orxonox
@@ -36,22 +36,24 @@
   ServerList::~ServerList()
   { /* delete the list */
-    serverlist.clear();}
+    serverlist.clear();
   }
 
-  int ServerList::addServer( ServerInformation *toadd )
+  int 
+  ServerList::addServer( packet::ServerInformation *toadd )
   { this->serverlist.push_back( toadd ); 
     return 0;
   }
 
-  bool ServerList::delServerByName( std::string name )
+  bool 
+  ServerList::delServerByName( std::string name )
   { 
     /* get an iterator */
-    list<ServerInformation *>::iterator i;
+    std::list<packet::ServerInformation *>::iterator i;
 
     /* loop through list elements */
     for( i = serverlist.begin(); i != serverlist.end(); ++i ) 
-      if( (*i)->serverName_ == name )
+      if( (*i)->getServerName() == name )
       { /* found this name, remove and quit */
-        this->serverlist.remove( i );
+        this->serverlist.remove( *i );
         return true;
       }
@@ -62,11 +64,11 @@
   { 
     /* get an iterator */
-    list<ServerInformation *>::iterator i;
+    std::list<packet::ServerInformation *>::iterator i;
 
     /* loop through list elements */
     for( i=serverlist.begin(); i != serverlist.end(); ++i ) 
-      if( (*i)->serverIP_ == address )
+      if( (*i)->getServerIP() == address )
       { /* found this name, remove and quit */
-        this->serverlist.remove( i );
+        this->serverlist.remove( *i );
         return true;
       }
@@ -76,6 +78,7 @@
 
   /* sort by name */
-  bool sub_compare_names( ServerInformation *no1, ServerInformation *no2 )
-  { return no1->serverName_ > no2->serverName_; }
+  bool sub_compare_names( packet::ServerInformation *no1, 
+    packet::ServerInformation *no2 )
+  { return no1->getServerName() > no2->getServerName(); }
 
   void ServerList::sortByName()
@@ -85,6 +88,10 @@
   
   /* sort by ping */
-  bool sub_compare_pings( ServerInformation *no1, ServerInformation *no2 )
-  { TODO return no1->serverName_ > no2->serverName_; }
+  bool sub_compare_pings( packet::ServerInformation *no1, 
+    packet::ServerInformation *no2 )
+  { 
+    /* TODO */
+    return no1->getServerName() > no2->getServerName();
+  }
 
   void ServerList::sortByPing()
Index: code/branches/masterserver/src/modules/masterserver/TestClient.cpp
===================================================================
--- code/branches/masterserver/src/modules/masterserver/TestClient.cpp	(revision 7589)
+++ code/branches/masterserver/src/modules/masterserver/TestClient.cpp	(revision 7589)
@@ -0,0 +1,113 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#include <cstdlib>
+#include <cstdio>
+#include <cstring>
+#include <enet/enet.h>
+
+int main( int argc, char *argv[] )
+{
+  /* initialize Enet */
+  if (enet_initialize () != 0)
+  { fprintf (stderr, "An error occurred while initializing ENet.\n");
+    return EXIT_FAILURE;
+  }
+  atexit (enet_deinitialize);
+
+  /* client handle */
+  ENetHost *client;
+
+  /* initiate the client */
+  client = enet_host_create( NULL /* create a client host */,
+      1,
+      2, /* allow up 2 channels to be used, 0 and 1 */
+      0, 
+      0 ); 
+
+  /* see if it worked */
+  if (client == NULL)
+  { fprintf (stderr, 
+      "An error occurred while trying to create an ENet client host.\n");
+    exit (EXIT_FAILURE);
+  }
+
+  ENetAddress address;
+  ENetEvent event;
+  ENetPeer *peer;
+
+  /* Connect to some.server.net:1234. */
+  enet_address_set_host (& address, argv[1] );
+  address.port = 1234;
+
+  /* Initiate the connection, allocating the two channels 0 and 1. */
+  peer = enet_host_connect(client, &address, 2, 0);    
+
+  if (peer == NULL )
+  { fprintf( stderr, 
+        "No available peers for initiating an ENet connection.\n");
+    exit (EXIT_FAILURE);
+  }
+
+  /* Wait up to 5 seconds for the connection attempt to succeed. */
+  if (enet_host_service (client, & event, 5000) > 0 &&
+      event.type == ENET_EVENT_TYPE_CONNECT)
+  { fprintf( stdout, "Connection to some.server.net:1234 succeeded." ); 
+    char *theinput = (char *)calloc( 100,1 );
+    while( true )
+    { 
+      fgets( theinput, 90, stdin );
+      if( !strncmp( theinput, "quit", 4 ) )
+        break;
+
+      /* send the data to the friend */
+      /* Create a reliable packet of size 7 containing "packet\0" */
+      ENetPacket * packet = enet_packet_create( theinput, 
+          strlen( theinput ) + 1, 
+          ENET_PACKET_FLAG_RELIABLE);
+
+      /* Send the packet to the peer over channel id 0. */
+      enet_peer_send (peer, 0, packet);
+
+      /* One could just use enet_host_service() instead. */
+      enet_host_flush( client );
+      if( packet ) free( packet );
+    }
+  }
+  else
+  {
+    /* Either the 5 seconds are up or a disconnect event was */
+    /* received. Reset the peer in the event the 5 seconds   */
+    /* had run out without any significant event.            */
+    enet_peer_reset (peer);
+    fprintf( stdout, "Connection to some.server.net:1234 failed." );
+    exit(EXIT_FAILURE);
+  }
+
+  enet_host_destroy(client);
+}
