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