summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2014-12-20 20:49:55 +0100
committerFlorian Jung <flo@windfisch.org>2014-12-20 20:49:55 +0100
commit5b27dd8c7e0003f9ba32d3934ae09e917c4d8541 (patch)
treea612b2ff45600891be3ce01f55d92ba71ac7eb92
parentbebe709f46a53e1752dc220070613df25c285e4f (diff)
client.c
-rw-r--r--client.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/client.c b/client.c
new file mode 100644
index 0000000..c0198c0
--- /dev/null
+++ b/client.c
@@ -0,0 +1,31 @@
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/socket.h>
+#include <string.h>
+#include <sys/un.h>
+
+#define SOCKETPATH "/home/flo/uds_socket"
+
+void die(const char* msg){perror(msg); exit(1);}
+
+int main()
+{
+
+ struct sockaddr_un my_sockaddr;
+ my_sockaddr.sun_family=AF_UNIX;
+ strcpy(my_sockaddr.sun_path, SOCKETPATH);
+ int sockaddrlen = strlen(my_sockaddr.sun_path) + sizeof(my_sockaddr.sun_family);
+
+ int sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (sockfd == -1) die("socket");
+
+
+ if (connect(sockfd, (struct sockaddr*) &my_sockaddr, sockaddrlen) == -1)
+ die("connect");
+
+ write(sockfd,"get\n",4);
+
+ close(sockfd);
+ return 0;
+}