diff options
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 +} + /* |