summaryrefslogtreecommitdiffstats
path: root/src/Net/Connection.h
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2008-06-27 04:08:33 +0200
committerMatthias Schiffer <matthias@gamezock.de>2008-06-27 04:08:33 +0200
commit86c1806046dea0bf7c2525d0aa591cdae9b3d330 (patch)
treeab3091e3f2201489383dc212a2b3b10f93dc5796 /src/Net/Connection.h
parentf5377412a89b2a7f422decd771dc8de49a5498fc (diff)
downloadmad-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.h15
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();}