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.
16 static const char rcsid[] = "$Id: ares__close_sockets.c,v 1.1 1998/08/13 18:06:22 ghudson Exp $";
21 #include "ares_private.h"
23 void ares__close_sockets(struct server_state *server)
25 struct send_request *sendreq;
27 /* Free all pending output buffers. */
30 /* Advance server->qhead; pull out query as we go. */
31 sendreq = server->qhead;
32 server->qhead = sendreq->next;
37 /* Reset any existing input buffer. */
38 if (server->tcp_buffer)
39 free(server->tcp_buffer);
40 server->tcp_buffer = NULL;
41 server->tcp_lenbuf_pos = 0;
43 /* Close the TCP and UDP sockets. */
44 if (server->tcp_socket != -1)
46 close(server->tcp_socket);
47 server->tcp_socket = -1;
49 if (server->udp_socket != -1)
51 close(server->udp_socket);
52 server->udp_socket = -1;