Index: branches/network/src/lib/network/network_manager.cc
===================================================================
--- branches/network/src/lib/network/network_manager.cc	(revision 6000)
+++ branches/network/src/lib/network/network_manager.cc	(revision 6007)
@@ -95,5 +95,5 @@
   }
 
-  this->tmpStream = new NetworkStream(ipAddress, NET_CLIENT);
+  this->tmpStream = new NetworkStream(ipAddress);
   return 1;
 }
@@ -106,5 +106,5 @@
 int NetworkManager::createServer(unsigned int port)
 {
-  this->tmpStream = new NetworkStream(port, NET_SERVER);
+  this->tmpStream = new NetworkStream(port);
   SDL_Delay(20);
   return 1;
@@ -120,5 +120,6 @@
 {
   /* creating a new network stream, it will register itself automaticaly to the class list */
-  this->tmpStream = new NetworkStream(address, sync, NET_CLIENT);
+  this->tmpStream = new NetworkStream(address);
+  this->tmpStream->connectSynchronizeable(sync);
 }
 
@@ -132,5 +133,6 @@
   PRINTF(0)("Create a new server socket\n");
   /* creating a new network stream, it will register itself automaticaly to the class list */
-  this->tmpStream = new NetworkStream(port, sync, NET_SERVER);
+  this->tmpStream = new NetworkStream(port);
+  this->tmpStream->connectSynchronizeable(sync);
 }
 
Index: branches/network/src/lib/network/network_stream.cc
===================================================================
--- branches/network/src/lib/network/network_stream.cc	(revision 6000)
+++ branches/network/src/lib/network/network_stream.cc	(revision 6007)
@@ -45,57 +45,25 @@
   /* initialize the references */
   this->type = NET_CLIENT;
-  this->networkSocket = new NetworkSocket();
   this->networkProtocol = new NetworkProtocol();
-  this->synchronizeables = NULL;
   this->connectionMonitor = new ConnectionMonitor();
 }
 
-NetworkStream::NetworkStream(IPaddress& address, NodeType type)
+NetworkStream::NetworkStream(IPaddress& address)
 {
-  this->type = type;
+  this->type = NET_CLIENT;
   this->init();
-  this->networkSocket = new NetworkSocket(address);
+  this->networkSockets.push_back(new NetworkSocket(address));
   this->networkProtocol = new NetworkProtocol();
-  this->synchronizeables = NULL;
   this->connectionMonitor = new ConnectionMonitor();
 }
 
 
-NetworkStream::NetworkStream(unsigned int port, NodeType type)
+NetworkStream::NetworkStream(unsigned int port)
 {
-  this->type = type;
+  this->type = NET_SERVER;
   this->init();
-  this->networkSocket = new NetworkSocket();
-//  this->networkSocket->listen(port);
+  this->serverSocket = new ServerSocket(port);
   this->networkProtocol = new NetworkProtocol();
-  this->synchronizeables = NULL;
   this->connectionMonitor = new ConnectionMonitor();
-}
-
-
-NetworkStream::NetworkStream(IPaddress& address, Synchronizeable& sync, NodeType type)
-    : DataStream()
-{
-  this->type = type;
-  this->init();
-  this->networkSocket = new NetworkSocket(address);
-  this->networkProtocol = new NetworkProtocol();
-  this->synchronizeables = &sync;
-  this->connectionMonitor = new ConnectionMonitor();
-  this->bActive = true;
-}
-
-
-NetworkStream::NetworkStream(unsigned int port, Synchronizeable& sync, NodeType type)
-    : DataStream()
-{
-  this->type = type;
-  this->init();
-  this->networkSocket = new NetworkSocket();
-//  this->networkSocket->listen(port);
-  this->networkProtocol = new NetworkProtocol();
-  this->synchronizeables = &sync;
-  this->connectionMonitor = new ConnectionMonitor();
-  this->bActive = true;
 }
 
@@ -105,6 +73,6 @@
   /* set the class id for the base object */
   this->setClassID(CL_NETWORK_STREAM, "NetworkStream");
-  this->state = NET_REC_HEADER;
   this->bActive = false;
+  this->serverSocket = NULL;
 }
 
@@ -112,9 +80,18 @@
 NetworkStream::~NetworkStream()
 {
+  if ( this->serverSocket )
+  {
+    serverSocket->close();
+    delete serverSocket;
+  }
 
-  networkSocket->disconnectServer();
-
-  if( this->networkSocket)
-    delete networkSocket;
+  for (NetworkSocketVector::iterator i = networkSockets.begin(); i!=networkSockets.end(); i++)
+  {
+    if ( *i )
+    {
+      (*i)->disconnectServer();
+      delete *i;
+    }
+  }
 
   delete connectionMonitor;
@@ -125,6 +102,7 @@
 void NetworkStream::connectSynchronizeable(Synchronizeable& sync)
 {
-  this->synchronizeables = &sync;
-  if( this->networkSocket != NULL)
+  this->synchronizeables.push_back(&sync);
+
+  if( this->networkSockets.size()>0 )
     this->bActive = true;
 }
@@ -133,4 +111,5 @@
 void NetworkStream::processData()
 {
+#if 0
   int dataLength = 0;
 
@@ -197,4 +176,4 @@
   }
 
-
+#endif
 }
Index: branches/network/src/lib/network/network_stream.h
===================================================================
--- branches/network/src/lib/network/network_stream.h	(revision 6000)
+++ branches/network/src/lib/network/network_stream.h	(revision 6007)
@@ -7,20 +7,19 @@
 #define _NETWORK_STREAM
 
+#include <vector>
+#include <list>
+
 #include "data_stream.h"
 #include "network_protocol.h"
+#include "server_socket.h"
 
 class Synchronizeable;
 class NetworkSocket;
+class ServerSocket;
 class ConnectionMonitor;
 class NetworkProtocol;
 
-
-//<! The state of the NetworkStream
-typedef enum NetStat {
-  NET_REC_HEADER = 0,                          //!< Waiting for header
-  NET_REC_DATA,                                //!< Waiting for data
-
-  NUM_STATES                                   //!< Number of states
-};
+typedef std::list<Synchronizeable*>  SynchronizeableList;
+typedef std::vector<NetworkSocket*> NetworkSocketVector;
 
 
@@ -30,9 +29,7 @@
   public:
     NetworkStream();
-    NetworkStream(IPaddress& address, NodeType type);
-    NetworkStream(unsigned int port, NodeType type);
+    NetworkStream(IPaddress& address);
+    NetworkStream(unsigned int port);
 
-    NetworkStream(IPaddress& address, Synchronizeable& sync, NodeType type);
-    NetworkStream(unsigned int port, Synchronizeable& sync, NodeType type);
     ~NetworkStream();
     void init();
@@ -48,8 +45,8 @@
     NetworkProtocol*       networkProtocol;
     ConnectionMonitor*     connectionMonitor;
-    Synchronizeable*       synchronizeables;
-    NetworkSocket*         networkSocket;
+    SynchronizeableList    synchronizeables;
+    NetworkSocketVector    networkSockets;
+    ServerSocket*          serverSocket;
     int                    type;
-    int                    state;
     Header                 packetHeader;
     bool                   bActive;
Index: branches/network/src/lib/network/server_socket.cc
===================================================================
--- branches/network/src/lib/network/server_socket.cc	(revision 6000)
+++ branches/network/src/lib/network/server_socket.cc	(revision 6007)
@@ -112,4 +112,11 @@
 NetworkSocket ServerSocket::getNewSocket( )
 {
+  if ( !listenSocket )
+  {
+    PRINTF(1)("listenSocket == NULL! Maybe you forgot to call listen()\n");
+    close();
+    return NULL;
+  }
+
   TCPsocket sock = SDLNet_TCP_Accept(listenSocket);
 
@@ -124,2 +131,13 @@
 }
 
+void ServerSocket::close( )
+{
+  if ( listenSocket )
+  {
+    SDLNet_TCP_Close( listenSocket );
+    listenSocket = NULL;
+  }
+
+  _isListening = false;
+}
+
Index: branches/network/src/lib/network/server_socket.h
===================================================================
--- branches/network/src/lib/network/server_socket.h	(revision 6000)
+++ branches/network/src/lib/network/server_socket.h	(revision 6007)
@@ -40,4 +40,5 @@
     bool listen( unsigned int port );
     NetworkSocket getNewSocket( void );
+    void close();
 };
 
