practice/racket/first_practice/hello-world-client.rkt

18 lines
410 B
Racket
Raw Normal View History

2017-09-06 18:36:16 -07:00
#lang racket
(require net/zmq)
(define ctxt (context 1))
(define sock (socket ctx `REQ))
(printf "Connecting to hello world server...\n")
(socket-connect! sock "tcp://localhost:5555")
(for ([request (in-range 10)])
(printf "Sending request ~a...\n" request)
(socket-send! sock #"Hello")
(define message (socket-recv! sock))
(printf "Received reply ~a [~a]\n" request message))
(context-close! ctxt)