Initial import of binutils 2.22 on the new vendor branch
[dragonfly.git] / test / testcases / io / select_3 / select_3.c
1 #include <err.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <sysexits.h>
5 #include <netinet/in.h>
6 #include <sys/select.h>
7 #include <sys/socket.h>
8 #include <sys/types.h>
9
10 #define MANY 80
11
12 int
13 main(int argc, char *argv[])
14 {
15     fd_set write_fds;
16     int fd[MANY+3], i, maxfd;
17
18     FD_ZERO(&write_fds);
19     for (i = 0; i < MANY; ++i) {
20         if ((fd[i] = socket(PF_INET, SOCK_DGRAM, 0)) == -1)
21             err(EX_OSERR, "socket(2) failure");
22
23         FD_SET(fd[i], &write_fds);
24         maxfd = fd[i];
25     }
26
27     i = select(maxfd+1, NULL, &write_fds, NULL, NULL);
28
29     if (i == MANY)
30         printf("ok\n");
31
32     return (0);
33 }