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>
39 write_cb(int fd
, short event
, void *arg
)
41 const char *test
= "test string";
44 len
= send(fd
, test
, strlen(test
) + 1, 0);
46 printf("%s: write %d%s\n", __func__
,
47 len
, len
? "" : " - means EOF");
52 EVUTIL_CLOSESOCKET(pair
[0]);
53 } else if (called
== 1)
60 main (int argc
, char **argv
)
65 if (signal(SIGPIPE
, SIG_IGN
) == SIG_ERR
)
69 if (evutil_socketpair(AF_UNIX
, SOCK_STREAM
, 0, pair
) == -1)
72 /* Initalize the event library */
75 /* Initalize one event */
76 event_set(&ev
, pair
[1], EV_WRITE
, write_cb
, &ev
);