def __init__(self, sock, protocol, addr, additionalData): Connection.__init__(self, sock, protocol) self.client = addr # Inform the protocol we've made a connection. protocol.makeConnection(self) # Now, we want to feed in the extra data BEFORE the reactor reads # anything additional from the socket. However, if we call this in # the other order, and the socket gets closed (or passed to something # non-twisted) after just the initial chunk, we'll be calling # startReading() on something we've already stopped reading. That won't # work too well... Fortunately, the reactor runs in this thread, so # merely adding it (with startReading()) can't cause a read to happen # immediately. self.startReading() self.connected = 1 protocol.dataReceived(additionalData)