aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2012-08-21 14:25:11 -0500
committerTed Gould <ted@gould.cx>2012-08-21 14:25:11 -0500
commite610f6f207135dd5513a2c3120bf0ae391db2910 (patch)
tree1e6d0a61e3860bb0e5b1206194c7421a10f53cc4
parent4dd6128c153ea94ea70a22a5d8a4fc50ea59ddbd (diff)
downloadlightdm-remote-session-arctica-e610f6f207135dd5513a2c3120bf0ae391db2910.tar.gz
lightdm-remote-session-arctica-e610f6f207135dd5513a2c3120bf0ae391db2910.tar.bz2
lightdm-remote-session-arctica-e610f6f207135dd5513a2c3120bf0ae391db2910.zip
Filling out the function based on some examples, basic stuff
-rw-r--r--socket-sucker.c34
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;
+ }
}
+