2 # -*- coding: utf-8 -*-
11 print "Running %s %r %r ..." % (f
.__name
__, a
, kw
)
17 sock
= socket
.socket()
18 sock
.setsockopt(socket
.SOL_SOCKET
, socket
.SO_REUSEADDR
, 1)
19 address
= ("localhost", 5000)
22 gobject
.io_add_watch(sock
, gobject
.IO_IN
, accept_ready
)
25 def accept_ready(sock
, cond
):
26 sock2
, addr
= sock
.accept()
31 def add_in_watch(sock2
):
32 gobject
.io_add_watch(sock2
, gobject
.IO_IN
, data_ready
)
35 def data_ready(sock2
, cond
):
36 data
= sock2
.recv(BUFLEN
)
52 mainloop
= gobject
.MainLoop()
61 if __name__
== "__main__":
63 sys
.exit(main(sys
.argv
))