From e67f935f3a90a96f0bc2a83c0d7e2ca092b132eb Mon Sep 17 00:00:00 2001
From: Martin Hurton <hurtonm@gmail.com>
Date: Mon, 24 Nov 2014 15:07:24 +0100
Subject: [PATCH] Fix issue #1257

---
 src/socket_base.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/socket_base.cpp b/src/socket_base.cpp
index 60e655ac..d4bd1f21 100644
--- a/src/socket_base.cpp
+++ b/src/socket_base.cpp
@@ -518,9 +518,6 @@ int zmq::socket_base_t::connect (const char *addr_)
         int rc = pipepair (parents, new_pipes, hwms, conflates);
         errno_assert (rc == 0);
 
-        //  Attach local end of the pipe to this socket object.
-        attach_pipe (new_pipes [0]);
-
         if (!peer.socket) {
             //  The peer doesn't exist yet so we don't know whether
             //  to send the identity message or not. To resolve this,
@@ -569,6 +566,9 @@ int zmq::socket_base_t::connect (const char *addr_)
             send_bind (peer.socket, new_pipes [1], false);
         }
 
+        //  Attach local end of the pipe to this socket object.
+        attach_pipe (new_pipes [0]);
+
         // Save last endpoint URI
         last_endpoint.assign (addr_);