diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2008-06-27 04:08:33 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2008-06-27 04:08:33 +0200 |
commit | 86c1806046dea0bf7c2525d0aa591cdae9b3d330 (patch) | |
tree | ab3091e3f2201489383dc212a2b3b10f93dc5796 /src/Net/Connection.h | |
parent | f5377412a89b2a7f422decd771dc8de49a5498fc (diff) | |
download | mad-86c1806046dea0bf7c2525d0aa591cdae9b3d330.tar mad-86c1806046dea0bf7c2525d0aa591cdae9b3d330.zip |
Aufwendigere Verarbeitung des Pollings, jetzt auch im Test-Client
Diffstat (limited to 'src/Net/Connection.h')
-rw-r--r-- | src/Net/Connection.h | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/Net/Connection.h b/src/Net/Connection.h index e147ad2..adb677a 100644 --- a/src/Net/Connection.h +++ b/src/Net/Connection.h @@ -136,6 +136,7 @@ class Connection { } const IPAddress* getPeer() {return peer;} + int getSocket() const {return sock;} void disconnect(); @@ -148,14 +149,22 @@ class Connection { return rawSend(reinterpret_cast<const unsigned char*>(packet.getRawData()), packet.getRawDataLength()); } - void sendReceive() { + void sendReceive(short events = POLLIN|POLLOUT) { + if(events & POLLHUP || events & POLLERR) { + disconnect(); + return; + } + if(state == HANDSHAKE) { doHandshake(); return; } - doReceive(); - doSend(); + if(events & POLLIN) + doReceive(); + + if(events & POLLOUT) + doSend(); } bool sendQueueEmpty() const {return transS.empty();} |