diff options
author | Pierre Ossman <ossman@cendio.se> | 2018-05-03 14:04:38 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2018-05-29 14:38:25 +0200 |
commit | 5d05546fe48512f8f2294b85aa09fa7c8cc1933c (patch) | |
tree | 28e66ae1856c86e0a6a26633b02548b9ba6b1316 /vncviewer/CConn.cxx | |
parent | e3a2be69c48893ef086110b8d92f1fadd004a997 (diff) | |
download | tigervnc-5d05546fe48512f8f2294b85aa09fa7c8cc1933c.tar.gz tigervnc-5d05546fe48512f8f2294b85aa09fa7c8cc1933c.zip |
Add support for Unix sockets
Patch originally by Dag-Erling Smørgrav for University of Oslo.
Diffstat (limited to 'vncviewer/CConn.cxx')
-rw-r--r-- | vncviewer/CConn.cxx | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/vncviewer/CConn.cxx b/vncviewer/CConn.cxx index 35d6e231..166597e5 100644 --- a/vncviewer/CConn.cxx +++ b/vncviewer/CConn.cxx @@ -39,6 +39,9 @@ #include <rdr/MemInStream.h> #include <rdr/MemOutStream.h> #include <network/TcpSocket.h> +#ifndef WIN32 +#include <network/UnixSocket.h> +#endif #include <FL/Fl.H> #include <FL/fl_ask.H> @@ -106,10 +109,19 @@ CConn::CConn(const char* vncServerName, network::Socket* socket=NULL) if(sock == NULL) { try { - getHostAndPort(vncServerName, &serverHost, &serverPort); +#ifndef WIN32 + if (strchr(vncServerName, '/') != NULL) { + sock = new network::UnixSocket(vncServerName); + serverHost = sock->getPeerAddress(); + vlog.info(_("connected to socket %s"), serverHost); + } else +#endif + { + getHostAndPort(vncServerName, &serverHost, &serverPort); - sock = new network::TcpSocket(serverHost, serverPort); - vlog.info(_("connected to host %s port %d"), serverHost, serverPort); + sock = new network::TcpSocket(serverHost, serverPort); + vlog.info(_("connected to host %s port %d"), serverHost, serverPort); + } } catch (rdr::Exception& e) { vlog.error("%s", e.str()); if (alertOnFatalError) |