<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>4.4 Overview of a Connection Handler</title> <META NAME="description" CONTENT="4.4 Overview of a Connection Handler"> <META NAME="keywords" CONTENT="modpython"> <META NAME="resource-type" CONTENT="document"> <META NAME="distribution" CONTENT="global"> <link rel="STYLESHEET" href="modpython.css"> <link rel="first" href="modpython.html"> <link rel="contents" href="contents.html" title="Contents"> <link rel="index" href="genindex.html" title="Index"> <LINK REL="next" href="module-apache.html"> <LINK REL="previous" href="pyapi-filter.html"> <LINK REL="up" href="pythonapi.html"> <LINK REL="next" href="module-apache.html"> </head> <body> <DIV CLASS="navigation"> <table align="center" width="100%" cellpadding="0" cellspacing="2"> <tr> <td><A href="pyapi-filter.html"><img src="icons/previous.png" border="0" height="32" alt="Previous Page" width="32"></A></td> <td><A href="pythonapi.html"><img src="icons/up.png" border="0" height="32" alt="Up One Level" width="32"></A></td> <td><A href="module-apache.html"><img src="icons/next.png" border="0" height="32" alt="Next Page" width="32"></A></td> <td align="center" width="100%">Mod_python Manual</td> <td><A href="contents.html"><img src="icons/contents.png" border="0" height="32" alt="Contents" width="32"></A></td> <td><img src="icons/blank.png" border="0" height="32" alt="" width="32"></td> <td><A href="genindex.html"><img src="icons/index.png" border="0" height="32" alt="Index" width="32"></A></td> </tr></table> <b class="navlabel">Previous:</b> <a class="sectref" href="pyapi-filter.html">4.3 Overview of a</A> <b class="navlabel">Up:</b> <a class="sectref" href="pythonapi.html">4. Python API</A> <b class="navlabel">Next:</b> <a class="sectref" href="module-apache.html">4.5 apache - Access</A> <br><hr> </DIV> <!--End of Navigation Panel--> <H1><A NAME="SECTION006400000000000000000"> </A> <BR> 4.4 Overview of a Connection Handler </H1> <a name="l2h-16"> </a> <P> A <i class="dfn">connection handler</i> handles the connection, starting almost immediately from the point the TCP connection to the server was made. <P> Unlike HTTP handlers, connection handlers receive a <i>connection</i> object as an argument. <P> Connection handlers can be used to implement protocols. Here is an example of a simple echo server: <P> Apache configuration: <dl><dd><pre class="verbatim"> PythonConnectionHandler echo </pre></dl> <P> Contents of <span class="file">echo.py</span> file: <P> <dl><dd><pre class="verbatim"> from mod_python import apache def connectionhandler(conn): while 1: conn.write(conn.readline()) return apache.OK </pre></dl> <P> <DIV CLASS="navigation"> <p><hr> <table align="center" width="100%" cellpadding="0" cellspacing="2"> <tr> <td><A href="pyapi-filter.html"><img src="icons/previous.png" border="0" height="32" alt="Previous Page" width="32"></A></td> <td><A href="pythonapi.html"><img src="icons/up.png" border="0" height="32" alt="Up One Level" width="32"></A></td> <td><A href="module-apache.html"><img src="icons/next.png" border="0" height="32" alt="Next Page" width="32"></A></td> <td align="center" width="100%">Mod_python Manual</td> <td><A href="contents.html"><img src="icons/contents.png" border="0" height="32" alt="Contents" width="32"></A></td> <td><img src="icons/blank.png" border="0" height="32" alt="" width="32"></td> <td><A href="genindex.html"><img src="icons/index.png" border="0" height="32" alt="Index" width="32"></A></td> </tr></table> <b class="navlabel">Previous:</b> <a class="sectref" href="pyapi-filter.html">4.3 Overview of a</A> <b class="navlabel">Up:</b> <a class="sectref" href="pythonapi.html">4. Python API</A> <b class="navlabel">Next:</b> <a class="sectref" href="module-apache.html">4.5 apache - Access</A> <hr> <span class="release-info">Release 3.1.0a, documentation updated on August 26, 2003.</span> </DIV> <!--End of Navigation Panel--> </BODY> </HTML>