diff options
Diffstat (limited to 'client.c')
-rw-r--r-- | client.c | 31 |
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; +} |