This is some kind of test of EOF ported from libevent.
 
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <unistd.h>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cerrno>
 
#include <eventxx>
 
int test_okay = 1;
int called = 0;
 
void
read_cb(int fd, short event, void *arg)
{
        char buf[256];
        int len;
 
        len = read(fd, buf, sizeof(buf));
 
        printf("%s: read %d%s\n", __func__,
            len, len ? "" : " - means EOF");
 
        if (len) {
                if (!called)
        } else if (called == 1)
                test_okay = 0;
 
        called++;
}
 
int
main (int argc, char **argv)
{
        const char* test = "test string";
        int pair[2];
 
        if (socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == -1)
                return (1);
 
        write(pair[0], test, strlen(test)+1);
        shutdown(pair[0], SHUT_WR);
 
        
 
 
 
        delete ev;
 
        return (test_okay);
}
 
eventxx::event< ccallback_type > cevent
Shortcut to C-style event.
Definition: eventxx:488
 
@ READ
Read event.
Definition: eventxx:194
 
Event dispatcher.
Definition: eventxx:549
 
int dispatch(int flags=0)
Main dispatcher loop.
Definition: eventxx:764
 
void add(basic_event &e, int priority=DEFAULT_PRIORITY)
Adds an event to the dispatcher.
Definition: eventxx:588
 
This is the specialization of eventxx::event for C-style callbacks.
Definition: eventxx:336