<pre><code class="section">I am working on an example from <a href="http://www-128.ibm.com/developerworks/cn/linux/network/l-twist/part1/index.html">here</a><br><br>from twisted.internet.app import Application<br>from twisted.internet.protocol
import Protocol, Factory<br><br>class Fibonacci(Protocol):<br> """Serve a sequence of Fibonacci numbers to all requesters"""<br><br>def dataReceived(self, data):<br> self.factory.new
= self.factory.a + self.factory.b<br> self.transport.write('%d' % self.factory.new)<br> self.factory.a = self.factory.b<br> self.factory.b = self.factory.new<br><br>def main():<br> import fib_server # Use script as namespace
<br> f = Factory()<br> f.protocol = fib_server.Fibonacci<br> f.a, f.b = 1, 1<br> application = Application("Fibonacci")<br> application.listenTCP(8888, f)<br> application.save()<br><br>if'__main__' == __name__:
<br> main()<span style="font-family: arial,sans-serif;"><br><br>I have questions as the following:<br></span></code></pre>
<ol>
<li><code class="section"><span style="font-family: arial,sans-serif;">I could not find where in the code above make a .tap file?</span></code></li>
<li><code class="section"><span style="font-family: arial,sans-serif;">testing
on "twistd -f Fibonacci.tap" got message "Failed to load application:
No module named fib_server".Can we use script as namespace?</span></code></li>
<li><span style="font-family: arial,sans-serif;"><br>
</span></li>
</ol>
Steve Han