 <p>In case you want to avoid repeating boilerplate, Python will soon have a standard module that does the <code>fork()</code> pair and standard-I/O manipulations (which you have not added to your program yet?) that make it a daemon. You can download and use this module right now, from:</p> <p><a href="http://pypi.python.org/pypi/python-daemon" rel="nofollow">http://pypi.python.org/pypi/python-daemon</a></p> <p>Running a TCP server in a separate thread is often as simple as:</p> <pre><code>import threading def my_tcp_server(): sock = socket.socket(...) sock.bind(...) sock.listen() while True: conn, address = sock.accept() ... ... talk on the connection ... ... conn.close() def main(): ... threading.Thread(target=my_tcp_server).start() ... </code></pre> <p>I strongly recommend <strong>against</strong> trying to get your file-reader thread and your socket-answering thread talking with a list and lock of your own devising; such schemes are hard to get working and hard to keep working. Instead, use the standard library's <code>Queue.Queue()</code> class which does all of the locking and appending correctly for you.</p>