1 /* Copyright 1998 by the Massachusetts Institute of Technology.
3 * Permission to use, copy, modify, and distribute this
4 * software and its documentation for any purpose and without
5 * fee is hereby granted, provided that the above copyright
6 * notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting
8 * documentation, and that the name of M.I.T. not be used in
9 * advertising or publicity pertaining to distribution of the
10 * software without specific, written prior permission.
11 * M.I.T. makes no representations about the suitability of
12 * this software for any purpose. It is provided "as is"
13 * without express or implied warranty.
17 #include <sys/types.h>
19 #ifdef HAVE_SYS_TIME_H
24 #include "ares_private.h"
26 int ares_fds(ares_channel channel, fd_set *read_fds, fd_set *write_fds)
28 struct server_state *server;
31 /* No queries, no file descriptors. */
32 if (!channel->queries)
36 for (i = 0; i < channel->nservers; i++)
38 server = &channel->servers[i];
39 if (server->udp_socket != ARES_SOCKET_BAD)
41 FD_SET(server->udp_socket, read_fds);
42 if (server->udp_socket >= nfds)
43 nfds = server->udp_socket + 1;
45 if (server->tcp_socket != ARES_SOCKET_BAD)
47 FD_SET(server->tcp_socket, read_fds);
49 FD_SET(server->tcp_socket, write_fds);
50 if (server->tcp_socket >= nfds)
51 nfds = server->tcp_socket + 1;