From 5b27dd8c7e0003f9ba32d3934ae09e917c4d8541 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Sat, 20 Dec 2014 20:49:55 +0100 Subject: client.c --- client.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 client.c 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 +#include +#include +#include +#include +#include + +#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; +} -- cgit v1.2.3