From 6139188d408ef5e107c1afaec1495c42d942d113 Mon Sep 17 00:00:00 2001 From: phoebos Date: Sat, 27 May 2023 15:04:10 +0000 Subject: test unix socket --- client-test.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 client-test.c (limited to 'client-test.c') 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 +#include +#include +#include +#include +#include +#include +#include + +#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; +} -- cgit 1.4.1-2-gfad0