diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2008-06-26 01:40:24 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2008-06-26 01:40:24 +0200 |
commit | fb949bfd7687696c47449aaea0e6a117d382d41c (patch) | |
tree | c3c406cc107857e8f7924298823153d5eaa55fcc | |
parent | 27fe7a9e94704e7bd5420b0c3b59016943f0a333 (diff) | |
download | mad-fb949bfd7687696c47449aaea0e6a117d382d41c.tar mad-fb949bfd7687696c47449aaea0e6a117d382d41c.zip |
Listener: Getrennte Verbindungen verwerfen
-rw-r--r-- | src/Net/Listener.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/Net/Listener.cpp b/src/Net/Listener.cpp index b981b20..3fb2415 100644 --- a/src/Net/Listener.cpp +++ b/src/Net/Listener.cpp @@ -84,8 +84,16 @@ ServerConnection* Listener::getConnection() { addrlen = sizeof(sa); } - for(std::list<ServerConnection*>::iterator con = connections.begin(); con != connections.end(); con++) { + for(std::list<ServerConnection*>::iterator con = connections.begin(); con != connections.end(); ++con) (*con)->sendReceive(); + + for(std::list<ServerConnection*>::iterator con = connections.begin(); con != connections.end();) { + if(!(*con)->isConnected()) { + delete *con; + connections.erase(con++); // Erase unincremented iterator + + continue; + } if(!(*con)->isConnecting()) { ServerConnection *connection = *con; @@ -93,6 +101,8 @@ ServerConnection* Listener::getConnection() { return connection; } + + ++con; } return 0; |