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