~ubuntu-branches/ubuntu/precise/pyzmq/precise

« back to all changes in this revision

Viewing changes to examples/eventloop/rep_server.py

  • Committer: Bazaar Package Importer
  • Author(s): Piotr Ożarowski
  • Date: 2011-02-15 09:08:36 UTC
  • mfrom: (2.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20110215090836-phh4slym1g6muucn
Tags: 2.0.10.1-2
* Team upload.
* Upload to unstable
* Add Breaks: ${python:Breaks}

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import zmq
2
 
from zmq.eventloop import ioloop
3
 
 
4
 
loop = ioloop.IOLoop.instance()
5
 
 
6
 
ctx = zmq.Context()
7
 
s = ctx.socket(zmq.REP)
8
 
s.bind('tcp://127.0.0.1:5555')
9
 
 
10
 
def rep_handler(sock, events):
11
 
    # We don't know how many recv's we can do?
12
 
    msg = sock.recv()
13
 
    # No guarantee that we can do the send. We need a way of putting the
14
 
    # send in the event loop.
15
 
    sock.send(msg)
16
 
 
17
 
loop.add_handler(s, rep_handler, zmq.POLLIN)
18
 
 
19
 
loop.start()
 
 
b'\\ No newline at end of file'