serverShutdown_8c-source.html
5.01 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xmlrpc: server/serverShutdown.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.8 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main Page</span></a></li>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File List</span></a></li>
<li><a href="globals.html"><span>Globals</span></a></li>
</ul>
</div>
<h1>server/serverShutdown.c</h1><a href="serverShutdown_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include <stdio.h></span> <span class="comment">/* for printf() and fprintf() */</span>
<a name="l00002"></a>00002 <span class="preprocessor">#include <sys/select.h></span> <span class="comment">/* for select system call and related */</span>
<a name="l00003"></a>00003 <span class="preprocessor">#include <sys/socket.h></span> <span class="comment">/* for select system call and related */</span>
<a name="l00004"></a>00004 <span class="preprocessor">#include <stdlib.h></span> <span class="comment">/* for exit */</span>
<a name="l00005"></a>00005 <span class="preprocessor">#include <string.h></span> <span class="comment">/* for memset and stuff */</span>
<a name="l00006"></a>00006 <span class="preprocessor">#include <unistd.h></span> <span class="comment">/* for getopt */</span>
<a name="l00007"></a>00007 <span class="preprocessor">#include <errno.h></span> <span class="comment">/* for errno */</span>
<a name="l00008"></a>00008
<a name="l00009"></a>00009 <span class="preprocessor">#include "../include/server.h"</span>
<a name="l00010"></a>00010 <span class="preprocessor">#include "../include/monitor.h"</span>
<a name="l00011"></a>00011 <span class="preprocessor">#include "../include/writeBuffer.h"</span>
<a name="l00012"></a>00012
<a name="l00013"></a>00013
<a name="l00014"></a>00014 <span class="keywordtype">void</span>
<a name="l00015"></a><a class="code" href="serverShutdown_8c.html#50decfdd3550b2490a1b9448a313cbf9">00015</a> <a class="code" href="server_8h.html#50decfdd3550b2490a1b9448a313cbf9">serverShutdown</a>(<a class="code" href="structtServer.html">tServer</a> * server)
<a name="l00016"></a>00016 {
<a name="l00017"></a>00017 <span class="keywordtype">int</span> i;
<a name="l00018"></a>00018
<a name="l00019"></a>00019 <span class="keywordflow">for</span> (i=3; i<=server-><a class="code" href="structtServer.html#145a672dfaec08ce54c02dbc9f3b11ae">maxFd</a>; i++) {
<a name="l00020"></a>00020 <span class="keywordflow">if</span> (FD_ISSET(i, &(server-><a class="code" href="structtServer.html#f1e1c8e11bd347994ebc641bcac4c0fb">socks</a>))) {
<a name="l00021"></a>00021 <span class="keywordflow">if</span> (i == server-><a class="code" href="structtServer.html#0f35110b14ced93ae0c47173e37d707d">servSock</a>) {
<a name="l00022"></a>00022 shutdown(server-><a class="code" href="structtServer.html#0f35110b14ced93ae0c47173e37d707d">servSock</a>, SHUT_RDWR);
<a name="l00023"></a>00023 close(server-><a class="code" href="structtServer.html#0f35110b14ced93ae0c47173e37d707d">servSock</a>);
<a name="l00024"></a>00024 } <span class="keywordflow">else</span> {
<a name="l00025"></a>00025 <span class="comment">/* actual do nothing except closing the client */</span>
<a name="l00026"></a>00026 <a class="code" href="client_8h.html#a9dad65338aa78062b23a924ae1d2b59">clientClose</a>(&((server-><a class="code" href="structtServer.html#1c13c660dcf97444bdeee1f52bace303">clients</a>)[i]));
<a name="l00027"></a>00027 FD_CLR(i, &(server-><a class="code" href="structtServer.html#f1e1c8e11bd347994ebc641bcac4c0fb">socks</a>));
<a name="l00028"></a>00028 }
<a name="l00029"></a>00029 }
<a name="l00030"></a>00030 }
<a name="l00031"></a>00031
<a name="l00032"></a>00032 <span class="keywordflow">if</span> (NULL != server-><a class="code" href="structtServer.html#8fc3e5e54d17d86d21874d5987a080af">wHandle</a>) {
<a name="l00033"></a>00033 fclose(server-><a class="code" href="structtServer.html#8fc3e5e54d17d86d21874d5987a080af">wHandle</a>);
<a name="l00034"></a>00034 }
<a name="l00035"></a>00035 }
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sun Oct 10 01:24:35 2010 for xmlrpc by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
</body>
</html>