diff options
Diffstat (limited to 'client-test.c')
-rw-r--r-- | client-test.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/client-test.c b/client-test.c new file mode 100644 index 0000000..1a8638d --- /dev/null +++ b/client-test.c @@ -0,0 +1,29 @@ +#include <err.h> +#include <errno.h> +#include <poll.h> +#include <stdio.h> +#include <string.h> +#include <sys/socket.h> +#include <sys/un.h> +#include <unistd.h> + +#define SOCK_PATH "/tmp/kissbot" + +int +main(void) { + struct sockaddr_un remote = {.sun_family = AF_UNIX}; + int s = socket(AF_UNIX, SOCK_STREAM, 0); + if (s == -1) + err(1, "socket"); + + strlcpy(remote.sun_path, SOCK_PATH, + sizeof(remote.sun_path)-1); + if (connect(s, (struct sockaddr *)&remote, + sizeof(SOCK_PATH) + sizeof(remote.sun_family)) == -1) + err(1, "connect"); + char msg[] = "Hi, test message 1!\n"; + if (send(s, msg, sizeof(msg), 0) == -1) + err(1, "send"); + close(s); + return 0; +} |