summaryrefslogtreecommitdiffstats
path: root/src/Net/Connection.h
diff options
context:
space:
mode:
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();}