From 86c1806046dea0bf7c2525d0aa591cdae9b3d330 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 27 Jun 2008 04:08:33 +0200 Subject: Aufwendigere Verarbeitung des Pollings, jetzt auch im Test-Client --- src/Net/Connection.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/Net/Connection.h') 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(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();} -- cgit v1.2.3