[zeromq-dev] simple python example for 0MQ/2.0
tom
tomschuring at gmail.com
Wed Oct 7 07:51:23 CEST 2009
hello,
i'm trying to use 0MQ/2.0 under python(2.5). the performance tests work fine
so i think i have done everything right in setting up my environment
(winXP).
now i'm trying to make a simple client - server example but the server never
receives messages from the client
mqserver.py:
-------------------------------------------------------------------
import libpyzmq
def main ():
server_address = "tcp://127.0.0.1:3251"
ctx = libpyzmq.Context(1, 1)
s = libpyzmq.Socket(ctx, libpyzmq.SUB)
s.setsockopt (libpyzmq.SUBSCRIBE , "*");
s.bind(server_address)
print "waiting for message"
amsg = s.recv()
print "received message: %s " % (amsg, )
if __name__ == "__main__":
main ()
-------------------------------------------------------------------
mqclient.py:
-------------------------------------------------------------------
import sys
import libpyzmq
def main ():
server_address = "tcp://127.0.0.1:3251"
ctx = libpyzmq.Context(1, 1)
s = libpyzmq.Socket (ctx, libpyzmq.PUB)
s.connect(server_address)
msg = sys.argv [1]
print "sending message: %s " % (msg, )
s.send(msg)
print "ended sending messages"
if __name__ == "__main__":
main ()
-------------------------------------------------------------------
as output of the client i get :
>mqclient.py bla
sending message: bla
ended sending messages
>_
but the server gets stuck on the "amsg = s.recv()" line, as seen by the
output:
>mqserver.py
waiting for message
i realize that i run the server and client on the same machine, but that
shouldn't make a difference (should it ?).
i have also tried the real ip address instead of 127.0.0.1 but nothing
works, is there something
any help would be appreciated,
thanks,
tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20091007/6196aeb4/attachment.htm>
More information about the zeromq-dev
mailing list