! hello world server USING: kernel io io.encodings.utf8 destructors byte-arrays calendar zmq zmq.ffi alien.data threads ; IN: zmq.examples.hello-world-server : hello-world-server ( -- ) 1 [ ZMQ_REP "tcp://*:5555" [ [ t ] [ dup utf8 recv-string print yield 1 seconds sleep [ "World" utf8 send-string ] keep ] while drop ] with-binding ] with-disposal ; MAIN: hello-world-server ! hello world client USING: kernel io io.encodings.utf8 destructors threads math.ranges formatting zmq zmq.ffi alien.data locals sequences arrays ; IN: zmq.examples.hello-world-client : hello-world-client ( -- ) 1 [ "Connecting to hello world server..." print ZMQ_REQ "tcp://localhost:5555" [ 10 [1,b] [| request | request "Sending request %d...\n" printf dup "Hello" utf8 send-string dup utf8 recv-string request swap "Received reply %d [ %s ]\n" printf yield ] each drop ] with-connection ] with-disposal ; MAIN: hello-world-client