2
# Copyright (c) 2007-2010 iMatix Corporation
4
# This file is part of 0MQ.
6
# 0MQ is free software; you can redistribute it and/or modify it under
7
# the terms of the Lesser GNU General Public License as published by
8
# the Free Software Foundation; either version 3 of the License, or
9
# (at your option) any later version.
11
# 0MQ is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# Lesser GNU General Public License for more details.
16
# You should have received a copy of the Lesser GNU General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
25
use_poll = '-p' in sys.argv
26
use_copy = '-c' in sys.argv
32
if len (sys.argv) != 4:
33
print 'usage: remote_thr [-c use-copy] [-p use-poll] <connect-to> <message-size> <message-count>'
37
connect_to = sys.argv[1]
38
message_size = int(sys.argv[2])
39
message_count = int(sys.argv[3])
40
except (ValueError, OverflowError), e:
41
print 'message-size and message-count must be integers'
45
s = ctx.socket(zmq.PUB)
47
# Add your socket options here.
48
# For example ZMQ_RATE, ZMQ_RECOVERY_IVL and ZMQ_MCAST_LOOP for PGM.
56
# Wait for this side to connect.
59
msg = ' ' * message_size
61
for i in range(0, message_count):
64
assert(res[0][1] & zmq.POLLOUT)
65
s.send(msg, zmq.NOBLOCK if use_poll else 0, copy=use_copy)
67
# Let the context finish messaging before ending.
68
# You may need to increase this time for longer or many messages.
71
if __name__ == "__main__":