diff options
author | Ted Gould <ted@gould.cx> | 2012-08-21 14:25:11 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2012-08-21 14:25:11 -0500 |
commit | 3541e56c2790c309f4f37795109a044e29c0c606 (patch) | |
tree | 1e6d0a61e3860bb0e5b1206194c7421a10f53cc4 | |
parent | 0125935a98fe858ee146ad05842f11ad9f2981e2 (diff) | |
download | lightdm-remote-session-freerdp2-3541e56c2790c309f4f37795109a044e29c0c606.tar.gz lightdm-remote-session-freerdp2-3541e56c2790c309f4f37795109a044e29c0c606.tar.bz2 lightdm-remote-session-freerdp2-3541e56c2790c309f4f37795109a044e29c0c606.zip |
Filling out the function based on some examples, basic stuff
-rw-r--r-- | socket-sucker.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/socket-sucker.c b/socket-sucker.c index 46af2d6..0b1ee27 100644 --- a/socket-sucker.c +++ b/socket-sucker.c @@ -1,13 +1,47 @@ +#include <stdlib.h> +#include <stdio.h> +#include <unistd.h> + +#include <sys/types.h> +#include <sys/socket.h> +#include <sys/un.h> + +#define BUFFER_SIZE 256 int main (int argc, char * argv[]) { + int socket_fd = 0; + int servlen = 0; + struct sockaddr_un serv_addr; + bzero((char *)&serv_addr, sizeof(serv_addr)); + serv_addr.sun_family = AF_UNIX; + strcpy(serv_addr.sun_path, "/home/ted/.freerdp-socket"); + servlen = strlen(serv_addr.sun_path) + sizeof(serv_addr.sun_family); + if ((socket_fd = socket(AF_UNIX, SOCK_STREAM,0)) < 0) { + return -1; + } + if (connect(socket_fd, (struct sockaddr *)&serv_addr, servlen) < 0) { + return -1; + } + char buffer[BUFFER_SIZE + 2]; + int in = 0; + int out = 0; + in = read(socket_fd, buffer, BUFFER_SIZE); + out = write(1, buffer, in); + close(socket_fd); + if (in == 0) { + return 0; + } else { + return -1; + } } + |