summaryrefslogtreecommitdiffstats
path: root/src/Net/Listener.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Net/Listener.cpp')
-rw-r--r--src/Net/Listener.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/Net/Listener.cpp b/src/Net/Listener.cpp
index 8386389..981b3c7 100644
--- a/src/Net/Listener.cpp
+++ b/src/Net/Listener.cpp
@@ -90,21 +90,28 @@ std::vector<struct pollfd> Listener::getPollfds() const {
return pollfds;
}
-ServerConnection* Listener::getConnection() {
+ServerConnection* Listener::getConnection(const std::map<int,const short*> &pollfdMap) {
// TODO: Logging
int sd;
struct sockaddr_in sa;
socklen_t addrlen = sizeof(sa);
+
while((sd = accept(sock, reinterpret_cast<struct sockaddr*>(&sa), &addrlen)) >= 0) {
connections.push_back(new ServerConnection(sd, IPAddress(sa), dh_params));
addrlen = sizeof(sa);
}
- 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(); ++con) {
+ std::map<int,const short*>::const_iterator events = pollfdMap.find((*con)->getSocket());
+
+ if(events != pollfdMap.end())
+ (*con)->sendReceive(*events->second);
+ else
+ (*con)->sendReceive();
+ }
for(std::list<ServerConnection*>::iterator con = connections.begin(); con != connections.end();) {
if(!(*con)->isConnected()) {