aboutsummaryrefslogtreecommitdiff
path: root/apiosend.c
blob: 0a98be01faabd3481ccc4d58709dddcd944f4b8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <sys/types.h>
#include <stdio.h>
#include <sys/socket.h>
#include <sys/un.h>

#define MAXLEN 480

int main() {
	int sock;
	if ((sock = socket(AF_UNIX,SOCK_DGRAM,0)) == -1) {
		perror("socket");
		return 1;
	}

	printf("%d\n",EOF);

	struct sockaddr_un addr;
	memset(&addr, 0, sizeof addr);
	addr.sun_family = AF_UNIX;
	strncpy(addr.sun_path, "bees.sock", 10);

	printf("%ld\n",sizeof addr.sun_path);

	char buf[MAXLEN];
	int i;
	char c;
	for (i = 0; i < MAXLEN && (c = getchar())!=EOF; i++)
		buf[i] = c;

	sendto(sock, buf, i, 0, (struct sockaddr *)&addr, sizeof addr);
	printf("%ld %ld\n",sizeof addr,sizeof (struct sockaddr_un));

	return 0;
}