summaryrefslogtreecommitdiff
path: root/lib/Socket.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Socket.cc')
-rw-r--r--lib/Socket.cc19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/Socket.cc b/lib/Socket.cc
index a8c5beb..1d93bb5 100644
--- a/lib/Socket.cc
+++ b/lib/Socket.cc
@@ -13,7 +13,7 @@
#include "Output.h"
#include "config.h"
-Socket::Socket() throw (GeneralException) : Handle(socket(AF_INET, SOCK_STREAM, 0)), connected(false), listening(false) {
+Socket::Socket() throw (GeneralException) : Handle(socket(AF_INET, SOCK_STREAM, 0)), connected(false), listening(false), writeclosed(false), readclosed(false) {
if (GetHandle() < 0) {
throw GeneralException(_("Error creating socket."));
}
@@ -34,13 +34,26 @@ bool Socket::IsListening(void) {
}
bool Socket::CanRead(void) {
- return connected;
+ return connected && !readclosed;
}
bool Socket::CanWrite(void) {
- return connected;
+ return connected && !writeclosed;
}
+void Socket::CloseWrite(void) {
+ if (!writeclosed) {
+ writeclosed = true;
+ shutdown(GetHandle(), 1);
+ }
+}
+
+void Socket::CloseRead(void) {
+ if (!readclosed) {
+ readclosed = true;
+ shutdown(GetHandle(), 0);
+ }
+}
/***********************************************\
* Toute la suite n'est pas à décrire. Consulter *