diff options
author | Ben Klopfenstein <benklop@gmail.com> | 2009-05-12 01:51:23 +0200 |
---|---|---|
committer | Johannes Schindelin <johannes.schindelin@gmx.de> | 2009-05-12 14:46:25 +0200 |
commit | d7c0b34b62c8edd302e273588bae7467ecbfb987 (patch) | |
tree | 33d09f8112f19a0be53820a429e81da43269f9b9 /libvncclient/sockets.c | |
parent | 4088906b1341709435318226790b06296420a5e2 (diff) | |
download | libvncserver-d7c0b34b62c8edd302e273588bae7467ecbfb987.zip libvncserver-d7c0b34b62c8edd302e273588bae7467ecbfb987.tar.gz |
libvncclient: Unix sockets support by Ben Klopfenstein
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Diffstat (limited to 'libvncclient/sockets.c')
-rw-r--r-- | libvncclient/sockets.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/libvncclient/sockets.c b/libvncclient/sockets.c index 7f350e2..5cfc743 100644 --- a/libvncclient/sockets.c +++ b/libvncclient/sockets.c @@ -38,6 +38,7 @@ #else #include <sys/socket.h> #include <netinet/in.h> +#include <sys/un.h> #include <netinet/tcp.h> #include <arpa/inet.h> #include <netdb.h> @@ -297,6 +298,34 @@ ConnectClientToTcpAddr(unsigned int host, int port) return sock; } +int +ConnectClientToUnixSock(const char *sockFile) +{ +#ifdef WIN32 + rfbClientErr("Windows doesn't support UNIX sockets\n"); + return -1; +#else + int sock; + struct sockaddr_un addr; + addr.sun_family = AF_UNIX; + strcpy(addr.sun_path, sockFile); + + sock = socket(AF_UNIX, SOCK_STREAM, 0); + if (sock < 0) { + rfbClientErr("ConnectToUnixSock: socket (%s)\n",strerror(errno)); + return -1; + } + + if (connect(sock, (struct sockaddr *)&addr, sizeof(addr.sun_family) + strlen(addr.sun_path)) < 0) { + rfbClientErr("ConnectToUnixSock: connect\n"); + close(sock); + return -1; + } + + return sock; +#endif +} + /* |