summary refs log blame commit diff stats
path: root/client-test.c
blob: 1a8638d37711e75d2edd11e1576f7092d69c6dbb (plain) (tree)




























                                                                     
#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;
}