[ create a new paste ] login | about

Project: circuits
Link: http://circuits.codepad.org/lbxa0QWb    [ raw code | fork ]

Python, pasted on Apr 10:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from circuits import Debugger, BaseComponent, handler
from circuits.net.socket import Server
from circuits.net.sockets import TCPServer, UNIXServer
from circuits.net.events import write

class Foo(Server):

    @handler('read')
    def _on_read(self, socket, data):
        print 'data=', data
        self.fire(write(socket, 'thanks for %d' % (len(data),)))

s = Foo('www')
s.bind(UNIXServer('/tmp/foo.socket', channel='www+unix'))
s.bind(TCPServer(8080, channel='www+tcp'))

s + Debugger(errors=True)
s.run()


Create a new paste based on this one


Comments: