#! /usr/bin/env python # ----------------------------------------------- # stream_noblock.py: Non-blocking stream server # ----------------------------------------------- import i2p from i2p import socket import thread, time S = socket.socket('Dave', socket.SOCK_STREAM) S.listen(10) # Queue up to 10 connections S.setblocking(False) # Non-blocking print 'Serving at:', S.dest def handle_connection(C): """Handle a single connection in a thread of its own.""" try: f = C.makefile() # File object req = f.readline() # Read HTTP request s = '