<!-- ** Proxy connections

     $Id: sect_tcp_conn.docbook 1164 2010-01-06 10:03:51Z ewald-arnold $
-->

<sect1 id="tcp_connection">
<title>Behaviour of TCP/IP Connections</title>

<para>There are several methods to fine-tune the behaviour of TCP/IP connections.
In case you need even more control you must retrieve the current file handle
with <methodname>getHandle()</methodname> or <methodname>getServerHandle()</methodname>
and call the appropriate operating system call.</para>

<para>&ulxmlrpcpp; tries to remain portable over all common platforms.
Unfortunately the following function may differ slightly on platforms. When using
the above mentioned handles on more specialized behaviour you might become
even more non-portable.</para>

<sect2 id="tcp_connection.no-delay">
<title>Disabling Buffer Mechanism</title>

<para>Under normal circumstances the TCP stack tries to buffer data and send
optimal large packets. So data is sent when either the buffer is full or
some timeout expires.</para>

<para>Unfortunately this behaviour might slowdown your &xmlrpc; transactions as
there are
often rather small packets below the buffer threshold. Then each transaction
is delayed some time. If you experience a significant slowdown and even have
low system load you might disable the buffer mechanism with
<methodname>setTcpNoDelay(true)</methodname>. In this case all data is sent immediately
even if the size is smaller than the optimal transmission size of the network
connection.</para>

</sect2>

<!-- ################################### -->

<sect2 id="tcp_connection.shutdown">
<title>Shutting a Socket Down</title>

<para>When using persistent connections it may be necessary to close only one
direction of the connection to prevent any more incoming data but still
be able to send the rest of the response. You can then use
<methodname>shutdown(mode)</methodname>
to disable either incoming or outgoing data or even both.
.</para>

</sect2>

<!-- ################################### -->

<sect2 id="tcp_connection.linger">
<title>Abort on Close</title>

<para>When the flag <token>SO_LINGER</token> is set on a socket, then a call
to <methodname>close()</methodname> is blocked until all buffered data is sent or some
timeout expires. Otherwise <methodname>close()</methodname> returns immediately.
Use <methodname>abortOnClose()</methodname> to set this socket option.</para>

</sect2>

</sect1>
