Receive data from client without using "dataReceived" function in Twisted
<p>How to receive the data from the client, bypassing the standard class function Protocol? For example,</p>

<pre><code>class TW(protocol.Protocol):
    def get_data(delim = '\n'):
        #some code
        return data
</code></pre>

<p>I.e, without using the function "dataReceived", and not freezing all other the server clients?</p>

<p>You can't bypass <code>dataReceived</code> unless you like doing things the hard way :D. You can do what ever you're doing in <code>get_data()</code> in <code>dataReceived()</code>. Alternatively, you could add a <code>data</code> param in your <code>get_data()</code> and do a callback form <code>dataReceived</code>.</p>

<pre><code>class TW(Protocol):
    def get_data(data, delim='\n'):
        # some code
        return result

    def dataReceived(self, data):
        result = self.get_data(data, delim='\r\n')
        # do some more stuff
</code></pre>

python server twisted twisted.internet