]> gitweb.factorcode.org Git - factor.git/blob - extra/zeromq/examples/hwclient.factor
core: Rename iota to <iota> so we can have TUPLE: iota ... ; instead of TUPLE: iota...
[factor.git] / extra / zeromq / examples / hwclient.factor
1 ! Copyright (C) 2012 Eungju PARK.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: byte-arrays destructors formatting io kernel sequences
4 strings zeromq zeromq.ffi ;
5 IN: zeromq.examples.hwclient
6
7 : hwclient ( -- )
8     [
9         <zmq-context> &dispose
10         "Connecting to hello world server…" print
11         ZMQ_REQ <zmq-socket> &dispose
12         dup "tcp://localhost:5555" zmq-connect
13         10 <iota> [
14             [ "Hello" dup rot "Sending %s %d...\n" printf
15               dupd >byte-array 0 zmq-send ]
16             [ [ dup 0 zmq-recv >string ] dip
17               "Received %s %d\n" printf flush ]
18             bi
19         ] each drop
20     ] with-destructors ;
21
22 MAIN: hwclient
23