9 #define ISSET(var, flag) ((var & flag) == flag)
13 int ssock = libtcp_open_pasivo(PORT); assert(ssock != -1);
14 struct pollfd pfds[MAX];
16 pfds[0].events = POLLIN | POLLPRI;
21 res = poll(pfds, pfds_size, 5000); assert(res != -1);
24 if (ISSET(pfds[0].revents, POLLIN)
25 || ISSET(pfds[0].revents, POLLPRI))
29 printf("Demasiadas conexiones, ignorando...\n");
32 pfds[pfds_size].fd = accept(ssock, NULL, NULL);
33 assert(pfds[pfds_size].fd != -1);
34 printf("Nueva conexión...\n");
35 pfds[pfds_size].events = POLLIN | POLLPRI;
38 for (int i = 1; i < pfds_size; ++i)
40 if (ISSET(pfds[i].revents, POLLIN)
41 || ISSET(pfds[i].revents, POLLPRI))
44 int recibidos = libtcp_receive_bin(pfds[i].fd, buf, 10);
45 //assert(recibidos == 10);
47 printf("recibido %s\n", buf);