3 * cc -I/usr/local/include -o time-test time-test.c -L/usr/local/lib -levent
13 #include <sys/types.h>
15 #ifdef HAVE_SYS_TIME_H
18 #ifdef HAVE_SYS_SOCKET_H
19 #include <sys/socket.h>
37 read_cb(int fd
, short event
, void *arg
)
42 len
= recv(fd
, buf
, sizeof(buf
), 0);
44 printf("%s: read %d%s\n", __func__
,
45 len
, len
? "" : " - means EOF");
50 } else if (called
== 1)
61 main (int argc
, char **argv
)
64 const char *test
= "test string";
67 if (evutil_socketpair(AF_UNIX
, SOCK_STREAM
, 0, pair
) == -1)
71 send(pair
[0], test
, strlen(test
)+1, 0);
72 shutdown(pair
[0], SHUT_WR
);
74 /* Initalize the event library */
77 /* Initalize one event */
78 event_set(&ev
, pair
[1], EV_READ
, read_cb
, &ev
);