codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
--- echoserver.py 2013-08-24 11:42:10.004415752 +1000 +++ echoserverunix.py 2013-11-14 20:21:15.670528278 +1000 @@ -1,16 +1,16 @@ #!/usr/bin/env python -"""Simple TCP Echo Server +"""Simple UNIX Echo Server -This example shows how you can create a simple TCP Server (an Echo Service) +This example shows how you can create a simple UNIX Server (an Echo Service) utilizing the builtin Socket Components that the circuits library ships with. """ from circuits import handler, Debugger -from circuits.net.sockets import TCPServer +from circuits.net.sockets import UNIXServer -class EchoServer(TCPServer): +class EchoServer(UNIXServer): @handler("read") def on_read(self, sock, data): @@ -28,7 +28,7 @@ return data # Start and "run" the system. -# Bind to port 0.0.0.0:9000 -app = EchoServer(9000) +# Bind to a UNIX Socket at /tmp/test.sock +app = EchoServer("/tmp/test.sock") Debugger().register(app) app.run()
Private
[
?
]
Run code
Submit