1 <?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html lang="en" xmlns="http://www.w3.org/1999/xhtml">
3 <title>Twisted Documentation: Twisted code examples</title>
4 <link href="../howto/stylesheet.css" rel="stylesheet" type="text/css"/>
8 <h1 class="title">Twisted code examples</h1>
9 <div class="toc"><ol><li><a href="#auto0">Simple Echo server and client</a></li><li><a href="#auto1">Chat</a></li><li><a href="#auto2">Echo server & client variants</a></li><li><a href="#auto3">AMP server & client variants</a></li><li><a href="#auto4">Perspective Broker</a></li><li><a href="#auto5">Cred</a></li><li><a href="#auto6">GUI</a></li><li><a href="#auto7">FTP examples</a></li><li><a href="#auto8">Logging</a></li><li><a href="#auto9">POSIX Specific Tricks</a></li><li><a href="#auto10">Miscellaneous</a></li></ol></div>
13 <h2>Simple Echo server and client<a name="auto0"/></h2>
15 <li><a href="simpleclient.py" shape="rect">simpleclient.py</a> - simple TCP client</li>
16 <li><a href="simpleserv.py" shape="rect">simpleserv.py</a> - simple TCP echo server</li>
19 <h2>Chat<a name="auto1"/></h2>
21 <li><a href="chatserver.py" shape="rect">chatserver.py</a> - shows how to communicate between clients</li>
24 <h2>Echo server & client variants<a name="auto2"/></h2>
26 <li><a href="echoserv.py" shape="rect">echoserv.py</a> - variant on a simple TCP echo server</li>
27 <li><a href="echoclient.py" shape="rect">echoclient.py</a> - variant on a simple TCP client</li>
28 <li><a href="echoserv_udp.py" shape="rect">echoserv_udp.py</a> - simplest possible
30 <li><a href="echoclient_udp.py" shape="rect">echoclient_udp.py</a> - simple UDP
32 <li><a href="echoserv_ssl.py" shape="rect">echoserv_ssl.py</a> - simple SSL server</li>
33 <li><a href="echoclient_ssl.py" shape="rect">echoclient_ssl.py</a> - simple SSL client</li>
36 <h2>AMP server & client variants<a name="auto3"/></h2>
38 <li><a href="ampserver.py" shape="rect">ampserver.py</a> - do math using AMP</li>
39 <li><a href="ampclient.py" shape="rect">ampclient.py</a> - do math using AMP</li>
42 <h2>Perspective Broker<a name="auto4"/></h2>
44 <li><a href="pbsimple.py" shape="rect">pbsimple.py</a> - simplest possible PB server</li>
45 <li><a href="pbsimpleclient.py" shape="rect">pbsimpleclient.py</a> - simplest possible PB
47 <li><a href="pbbenchclient.py" shape="rect">pbbenchclient.py</a> - benchmarking client</li>
48 <li><a href="pbbenchserver.py" shape="rect">pbbenchserver.py</a> - benchmarking server</li>
49 <li><a href="pbecho.py" shape="rect">pbecho.py</a> - echo server that uses login</li>
50 <li><a href="pbechoclient.py" shape="rect">pbechoclient.py</a> - echo client using login</li>
51 <li><a href="pb_exceptions.py" shape="rect">pb_exceptions.py</a> - example of exceptions over PB</li>
52 <li><a href="pbgtk2.py" shape="rect">pbgtk2.py</a> - example of using GTK2 with PB</li>
53 <li><a href="pbinterop.py" shape="rect">pbinterop.py</a> - shows off various types supported by PB</li>
54 <li><a href="bananabench.py" shape="rect">bananabench.py</a> - benchmark for banana</li>
57 <h2>Cred<a name="auto5"/></h2>
59 <li><a href="cred.py" shape="rect">cred.py</a> - Authenticate a user with an in-memory username/password
61 <li><a href="dbcred.py" shape="rect">dbcred.py</a> - Using a database backend to authenticate a user</li>
64 <h2>GUI<a name="auto6"/></h2>
66 <li><a href="wxdemo.py" shape="rect">wxdemo.py</a> - demo of wxPython integration with Twisted</li>
67 <li><a href="pbgtk2.py" shape="rect">pbgtk2.py</a> - example of using GTK2 with PB</li>
68 <li><a href="pyuidemo.py" shape="rect">pyuidemo.py</a> - PyUI</li>
71 <h2>FTP examples<a name="auto7"/></h2>
73 <li><a href="ftpclient.py" shape="rect">ftpclient.py</a> - example of using the FTP client</li>
74 <li><a href="ftpserver.py" shape="rect">ftpserver.py</a> - create an FTP server which
75 serves files for anonymous users from the working directory and serves
76 files for authenticated users from <code class="shell">/home</code>.</li>
79 <h2>Logging<a name="auto8"/></h2>
81 <li><a href="twistd-logging.tac" shape="rect">twistd-logging.tac</a> - logging example using
83 <li><a href="testlogging.py" shape="rect">testlogging.py</a> - use twisted.python.log to log errors to
85 <li><a href="rotatinglog.py" shape="rect">rotatinglog.py</a> - example of log file rotation</li>
88 <h2>POSIX Specific Tricks<a name="auto9"/></h2>
90 <li><a href="sendfd.py" shape="rect">sendfd.py</a>, <a href="recvfd.py" shape="rect">recvfd.py</a> - send and receive
91 file descriptors over UNIX domain sockets
95 <h2>Miscellaneous<a name="auto10"/></h2>
97 <li><a href="shaper.py" shape="rect">shaper.py</a> - example of rate-limiting your web server</li>
98 <li><a href="stdiodemo.py" shape="rect">stdiodemo.py</a> - example using stdio, Deferreds, LineReceiver
99 and twisted.web.client.</li>
100 <li><a href="mouse.py" shape="rect">mouse.py</a> - example using MouseMan protocol with the SerialPort
102 <li><a href="ptyserv.py" shape="rect">ptyserv.py</a> - serve shells in pseudo-terminals over TCP</li>
103 <li><a href="courier.py" shape="rect">courier.py</a> - example of interfacing to Courier's mail filter
105 <li><a href="longex.py" shape="rect">longex.py</a> - example of doing arbitarily long calculations nicely
107 <li><a href="longex2.py" shape="rect">longex2.py</a> - using generators to do long calculations</li>
108 <li><a href="stdin.py" shape="rect">stdin.py</a> - reading a line at a time from standard input
109 without blocking the reactor</li>
110 <li><a href="streaming.py" shape="rect">streaming.py</a> - example of a push producer/consumer system</li>
111 <li><a href="filewatch.py" shape="rect">filewatch.py</a> - write the content of a file to standard out
112 one line at a time</li>
113 <li><a href="shoutcast.py" shape="rect">shoutcast.py</a> - example Shoutcast client</li>
114 <li><a href="gpsfix.py" shape="rect">gpsfix.py</a> - example using the SerialPort transport and GPS
115 protocols to display fix data as it is received from the device</li>
116 <li><a href="wxacceptance.py" shape="rect">wxacceptance.py</a> - acceptance tests for wxreactor</li>
117 <li><a href="postfix.py" shape="rect">postfix.py</a> - test application for PostfixTCPMapServer</li>
122 <p><a href="../howto/index.html">Index</a></p>
123 <span class="version">Version: 12.1.0</span>