clientClose.c
993 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdlib.h> /* for free() */
#include <unistd.h> /* for close() */
#include <sys/socket.h> /* for shutdown() */
#include <string.h> /* for memset and stuff */
#include <expat.h>
#include "../../include/client.h"
#include "../../include/monitor.h"
#include "../../include/httpRequest.h"
void clientClose(tClient * client)
{
if (0 != verbose) {
syslog(LOG_INFO, "closing socket for %s", client->remoteAddr);
}
/* close socket an remove from fd_set */
shutdown(client->socket, SHUT_RDWR);
close(client->socket);
/* free readBuffer */
if (NULL != client->readBuffer) {
free(client->readBuffer);
client->readBuffer = NULL;
}
if (NULL != client->writeBuffer) {
free(client->writeBuffer);
client->writeBuffer = NULL;
}
client->readPos = 0;
client->writePos = 0;
freeHttpHeader(&(client->httpHeader));
XML_ParserFree(client->parser);
memset(client->remoteAddr, 0, 16);
}