2 * Copyright (C) 1994, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.1 1995-03-10 18:22:44 quinn
8 * The rudiments of an asynchronous server.
14 #include <sys/types.h>
22 IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags)
26 if (!(new = malloc(sizeof(*new))))
35 void iochan_destroy(IOCHAN i)
45 fd_set in, out, except;
51 for (p = iochans; p; p = p->next)
53 if (p->flags & EVENT_INPUT)
55 if (p->flags & EVENT_OUTPUT)
57 if (p->flags & EVENT_EXCEPT)
58 FD_SET(p->fd, &except);
62 if ((res = select(max + 1, &in, &out, &except, 0)) < 0)
70 for (p = iochans; p; p = nextp)
73 if (FD_ISSET(p->fd, &in))
74 (*p->fun)(p, EVENT_INPUT);
75 if (!p->destroyed && FD_ISSET(p->fd, &in))
76 (*p->fun)(p, EVENT_OUTPUT);
77 if (!p->destroyed && FD_ISSET(p->fd, &except))
78 (*p->fun)(p, EVENT_EXCEPT);
87 for (pr = iochans; pr; pr = pr->next)