3 * c++ -I$(LIBEV_SRC) -o io-test-eof -DEV_STANDALONE=1 io-test-eof.cpp $(LIBEV_SRC)/ev.c $(LIBEV_SRC)/event.c
6 * Wed 2006-12-27 - Modified by Leandro Lucarella <llucax+eventxx@gmail.com>
8 * Adapted to test the C++ inteface.
10 * Wed 2007-12-19 - Modified by Chris Brody <chris.brody@gmail.com>
12 * Adapted to test the ioevent C++ inteface.
16 #include <sys/types.h>
19 #include <sys/socket.h>
35 read_cb(int fd
, short event
, void *arg
)
40 len
= read(fd
, buf
, sizeof(buf
));
42 printf("%s: read %d%s\n", __func__
,
43 len
, len
? "" : " - means EOF");
56 main (int argc
, char **argv
)
58 const char * test
= "test string";
61 IOLOOP loop
= ioloop_new();
63 if (socketpair(AF_UNIX
, SOCK_STREAM
, 0, pair
) == -1)
66 write(pair
[0], test
, strlen(test
)+1);
67 shutdown(pair
[0], SHUT_WR
);
70 ev
= new ioevent(pair
[1], EV_READ
, read_cb
, NULL
);
74 ioloop_dispatch(loop
);