# ZMQ - correct usage 

**URL:** https://discourse.julialang.org/t/zmq-correct-usage/9734
**Category:** General Usage
**Created:** [March 15, 2018, 11:17am UTC](https://discourse.julialang.org/t/zmq-correct-usage/9734 "2018-03-15T11:17:44Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![msomers](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@msomers](https://discourse.julialang.org/u/msomers)
#### Post date: [March 15, 2018, 11:17am UTC](https://discourse.julialang.org/t/zmq-correct-usage/9734/1 "2018-03-15T11:17:44Z")

</div>

trying to get a simple ZMQ communication going connecting to a simple python echo server

```julia
import zmq

# ZeroMQ Context
context = zmq.Context()

# Define the socket using the "Context"
sock = context.socket(zmq.REP)
sock.bind("tcp://127.0.0.1:1234")

# Run a simple "Echo" server
while True:
    message = sock.recv()
    sock.send("Echo: " + message)
    print "Echo: " + message

```

Julia code for the client looks like

```julia
using ZMQ
const ctx = Context()
const sock = Socket(ctx, REQ)
ZMQ.connect(sock, "tcp://127.0.0.1:1234")
ZMQ.send(sock, "SUCCESS")

```

that works for the first connection - but there doesn’t appear to be persistance if I send  
ZMQ.send(sock, “SUCCESS”)

I have to reestablish context like

```julia
ctx = Context()
s = Socket(ctx, REQ)
ZMQ.connect(s, "tcp://localhost:1234")

```

and not

`ZMQ.send(sock, "SUCCESS")`

that cant be right is it  
tks

---

<div class="post-metadata">

### Author: ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)
#### Post date: [March 15, 2018, 2:35pm UTC](https://discourse.julialang.org/t/zmq-correct-usage/9734/2 "2018-03-15T14:35:51Z")

</div>

You need to call `recv(sock)` from Julia after every time you call `send`, otherwise you won’t be able to send any more messages. This is just part of the required behavior of a REQ-REP connection.
