diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/unixsocket.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/tools/unixsocket.c b/src/tools/unixsocket.c new file mode 100644 index 000000000..88475ea3e --- /dev/null +++ b/src/tools/unixsocket.c | |||
@@ -0,0 +1,29 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <sys/types.h> | ||
3 | #include <sys/socket.h> | ||
4 | #include <sys/un.h> | ||
5 | |||
6 | int main(void) { | ||
7 | struct sockaddr_un addr; | ||
8 | int s; | ||
9 | const char *socketpath = "/var/run/minissdpd.sock"; | ||
10 | // const char *socketpath = "/var/run/acipd.sock"; | ||
11 | |||
12 | s = socket(AF_UNIX, SOCK_STREAM, 0); | ||
13 | if(s < 0) { | ||
14 | fprintf(stderr, "Error: cannot open socket\n"); | ||
15 | return 1; | ||
16 | } | ||
17 | |||
18 | addr.sun_family = AF_UNIX; | ||
19 | strncpy(addr.sun_path, socketpath, sizeof(addr.sun_path)); | ||
20 | if(connect(s, (struct sockaddr *)&addr, sizeof(struct sockaddr_un)) < 0) { | ||
21 | fprintf(stderr, "Error: cannot connect to socket\n"); | ||
22 | return 1; | ||
23 | } | ||
24 | |||
25 | printf("connected to %s\n", socketpath); | ||
26 | close(s); | ||
27 | |||
28 | return 0; | ||
29 | } | ||