reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
ares__close_sockets.c
Go to the documentation of this file.
1/* Copyright 1998 by the Massachusetts Institute of Technology.
2 *
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.
14 */
15
16#include <stdlib.h>
17#ifndef WIN32
18#include <unistd.h>
19#endif
20
21#include "ares.h"
22#include "ares_private.h"
23
25 if ( channel->poll_cb_func ) {
26 struct server_state *server = &channel->servers[server_idx];
27 if ( server->udp_socket!=-1 )
28 (*(channel->poll_cb_func))( channel->poll_cb_data,
29 channel, server_idx, server->udp_socket, 0, ARES_POLLACTION_CLOSE);
30 if ( server->tcp_socket!=-1 )
31 (*(channel->poll_cb_func))( channel->poll_cb_data,
32 channel, server_idx, server->tcp_socket, 1, ARES_POLLACTION_CLOSE);
33 }
34}
35
37{
38 struct send_request *sendreq;
39
40 /* Free all pending output buffers. */
41 while (server->qhead)
42 {
43 /* Advance server->qhead; pull out query as we go. */
44 sendreq = server->qhead;
45 server->qhead = sendreq->next;
47 }
48 server->qtail = NULL;
49
50 /* Reset any existing input buffer. */
51 if (server->tcp_buffer)
52 free(server->tcp_buffer);
53 server->tcp_buffer = NULL;
54 server->tcp_lenbuf_pos = 0;
55
56 /* Close the TCP and UDP sockets. */
57 if (server->tcp_socket != -1)
58 {
60 server->tcp_socket = -1;
61 }
62 if (server->udp_socket != -1)
63 {
65 server->udp_socket = -1;
66 }
67}
@ ARES_POLLACTION_CLOSE
Definition ares.h:130
void ares__close_poll(ares_channel channel, int server_idx)
void ares__close_sockets(struct server_state *server)
void ares__kill_socket(int s)
ares_poll_cb_func * poll_cb_func
struct server_state * servers
struct send_request * next
struct send_request * qhead
struct send_request * qtail
unsigned char * tcp_buffer
void list()
Definition userAdmin.cxx:66