serverShutdown_8c-source.html 5.01 KB
<!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&nbsp;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&nbsp;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&nbsp;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 &lt;stdio.h&gt;</span>      <span class="comment">/* for printf() and fprintf() */</span>
<a name="l00002"></a>00002 <span class="preprocessor">#include &lt;sys/select.h&gt;</span> <span class="comment">/* for select system call and related */</span>
<a name="l00003"></a>00003 <span class="preprocessor">#include &lt;sys/socket.h&gt;</span> <span class="comment">/* for select system call and related */</span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>     <span class="comment">/* for exit */</span>
<a name="l00005"></a>00005 <span class="preprocessor">#include &lt;string.h&gt;</span>     <span class="comment">/* for memset and stuff */</span>
<a name="l00006"></a>00006 <span class="preprocessor">#include &lt;unistd.h&gt;</span>     <span class="comment">/* for getopt */</span>
<a name="l00007"></a>00007 <span class="preprocessor">#include &lt;errno.h&gt;</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&lt;=server-&gt;<a class="code" href="structtServer.html#145a672dfaec08ce54c02dbc9f3b11ae">maxFd</a>; i++) {
<a name="l00020"></a>00020         <span class="keywordflow">if</span> (FD_ISSET(i, &amp;(server-&gt;<a class="code" href="structtServer.html#f1e1c8e11bd347994ebc641bcac4c0fb">socks</a>))) {
<a name="l00021"></a>00021             <span class="keywordflow">if</span> (i == server-&gt;<a class="code" href="structtServer.html#0f35110b14ced93ae0c47173e37d707d">servSock</a>) {
<a name="l00022"></a>00022                 shutdown(server-&gt;<a class="code" href="structtServer.html#0f35110b14ced93ae0c47173e37d707d">servSock</a>, SHUT_RDWR);
<a name="l00023"></a>00023                 close(server-&gt;<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>(&amp;((server-&gt;<a class="code" href="structtServer.html#1c13c660dcf97444bdeee1f52bace303">clients</a>)[i]));
<a name="l00027"></a>00027                 FD_CLR(i, &amp;(server-&gt;<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-&gt;<a class="code" href="structtServer.html#8fc3e5e54d17d86d21874d5987a080af">wHandle</a>) {
<a name="l00033"></a>00033         fclose(server-&gt;<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&nbsp;
<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>