1 /* $Id: miniupnpdctl.c,v 1.10 2012/04/30 21:08:00 nanard Exp $ */
3 * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
4 * (c) 2006-2012 Thomas Bernard
5 * This software is subject to the conditions detailed
6 * in the LICENCE file provided within the distribution */
12 #include <sys/types.h>
13 #include <sys/socket.h>
20 static void sighandler(int sig
)
22 printf("received signal %d\n", sig
);
27 main(int argc
, char * * argv
)
29 /*char test[] = "test!";*/
30 static const char command
[] = "show all\n";
34 struct sockaddr_un addr
;
38 /*signal(SIGINT, sighandler);*/
39 s
= socket(AF_UNIX
, SOCK_STREAM
, 0);
45 addr
.sun_family
= AF_UNIX
;
46 strncpy(addr
.sun_path
, "/var/run/miniupnpd.ctl",
47 sizeof(addr
.sun_path
));
48 if(connect(s
, (struct sockaddr
*)&addr
, sizeof(struct sockaddr_un
)) < 0)
55 printf("Connected.\n");
56 if(write(s
, command
, sizeof(command
)) < 0)
64 l
= read(s
, buf
, sizeof(buf
));
72 /*printf("%d bytes read\n", l);*/
74 if(write(fileno(stdout
), buf
, l
) < 0) {
75 perror("error writing to stdout");