00001 /* Copyright 1998 by the Massachusetts Institute of Technology. 00002 * 00003 * Permission to use, copy, modify, and distribute this 00004 * software and its documentation for any purpose and without 00005 * fee is hereby granted, provided that the above copyright 00006 * notice appear in all copies and that both that copyright 00007 * notice and this permission notice appear in supporting 00008 * documentation, and that the name of M.I.T. not be used in 00009 * advertising or publicity pertaining to distribution of the 00010 * software without specific, written prior permission. 00011 * M.I.T. makes no representations about the suitability of 00012 * this software for any purpose. It is provided "as is" 00013 * without express or implied warranty. 00014 * 00015 * CHANGELOG: this file has been modified by Sergio Perez Alcañiz <serpeal@disca.upv.es> 00016 * Departamento de Informática de Sistemas y Computadores 00017 * Universidad Politécnica de Valencia 00018 * Valencia (Spain) 00019 * Date: April 2003 00020 * 00021 */ 00022 00023 #include "ares_private.h" 00024 00025 void ares__close_sockets(struct server_state *server) 00026 { 00027 struct send_request *sendreq; 00028 00029 /* Free all pending output buffers. */ 00030 while (server->qhead) 00031 { 00032 /* Advance server->qhead; pull out query as we go. */ 00033 sendreq = server->qhead; 00034 server->qhead = sendreq->next; 00035 free(sendreq); 00036 } 00037 server->qtail = NULL; 00038 00039 /* Reset any existing input buffer. */ 00040 if (server->tcp_buffer) 00041 free(server->tcp_buffer); 00042 server->tcp_buffer = NULL; 00043 server->tcp_lenbuf_pos = 0; 00044 00045 /* Close the TCP and UDP sockets. */ 00046 if (server->tcp_socket != -1) 00047 { 00048 close(server->tcp_socket); 00049 server->tcp_socket = -1; 00050 } 00051 if (server->udp_socket != -1) 00052 { 00053 close(server->udp_socket); 00054 server->udp_socket = -1; 00055 } 00056 }