aboutsummaryrefslogtreecommitdiffstats
path: root/common/network/Socket.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'common/network/Socket.cxx')
-rw-r--r--common/network/Socket.cxx31
1 files changed, 21 insertions, 10 deletions
diff --git a/common/network/Socket.cxx b/common/network/Socket.cxx
index 49abbc84..7fc39d1e 100644
--- a/common/network/Socket.cxx
+++ b/common/network/Socket.cxx
@@ -32,22 +32,23 @@
#define errorNumber errno
#define closesocket close
#include <sys/socket.h>
-#endif
-
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <errno.h>
+#endif
-#include <rdr/Exception.h>
+#include <core/Exception.h>
+#include <core/LogWriter.h>
-#include <network/Socket.h>
+#include <rdr/FdInStream.h>
+#include <rdr/FdOutStream.h>
-#include <rfb/LogWriter.h>
+#include <network/Socket.h>
using namespace network;
-static rfb::LogWriter vlog("Socket");
+static core::LogWriter vlog("Socket");
// -=- Socket initialisation
static bool socketsInitialised = false;
@@ -59,7 +60,7 @@ void network::initSockets() {
WSADATA initResult;
if (WSAStartup(requiredVersion, &initResult) != 0)
- throw rdr::socket_error("Unable to initialise Winsock2", errorNumber);
+ throw core::socket_error("Unable to initialise Winsock2", errorNumber);
#else
signal(SIGPIPE, SIG_IGN);
#endif
@@ -99,6 +100,11 @@ Socket::~Socket()
delete outstream;
}
+int Socket::getFd()
+{
+ return outstream->getFd();
+}
+
// if shutdown() is overridden then the override MUST call on to here
void Socket::shutdown()
{
@@ -114,7 +120,7 @@ void Socket::shutdown()
}
isShutdown_ = true;
- ::shutdown(getFd(), SHUT_RDWR);
+ ::shutdown(getFd(), SHUT_WR);
}
bool Socket::isShutdown() const
@@ -122,6 +128,11 @@ bool Socket::isShutdown() const
return isShutdown_;
}
+void Socket::cork(bool enable)
+{
+ outstream->cork(enable);
+}
+
// Was there a "?" in the ConnectionFilter used to accept this Socket?
void Socket::setRequiresQuery()
{
@@ -178,7 +189,7 @@ Socket* SocketListener::accept() {
// Accept an incoming connection
if ((new_sock = ::accept(fd, nullptr, nullptr)) < 0)
- throw rdr::socket_error("Unable to accept new connection", errorNumber);
+ throw core::socket_error("Unable to accept new connection", errorNumber);
// Create the socket object & check connection is allowed
Socket* s = createSocket(new_sock);
@@ -196,7 +207,7 @@ void SocketListener::listen(int sock)
if (::listen(sock, 5) < 0) {
int e = errorNumber;
closesocket(sock);
- throw rdr::socket_error("Unable to set socket to listening mode", e);
+ throw core::socket_error("Unable to set socket to listening mode", e);
}
fd = sock;