summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tcp_listener.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/tcp_listener.cpp b/src/tcp_listener.cpp
index c3dc0b6..205ddc1 100644
--- a/src/tcp_listener.cpp
+++ b/src/tcp_listener.cpp
@@ -201,14 +201,20 @@ int zmq::tcp_listener_t::set_address (const char *protocol_, const char *addr_,
// Bind the socket to the network interface and port.
rc = bind (s, (struct sockaddr*) &addr, addr_len);
if (rc != 0) {
- close ();
+ int err = errno;
+ if (close () != 0)
+ return -1;
+ errno = err;
return -1;
}
// Listen for incomming connections.
rc = listen (s, backlog_);
if (rc != 0) {
- close ();
+ int err = errno;
+ if (close () != 0)
+ return -1;
+ errno = err;
return -1;
}
@@ -241,7 +247,10 @@ int zmq::tcp_listener_t::set_address (const char *protocol_, const char *addr_,
// Bind the socket to the file path.
rc = bind (s, (struct sockaddr*) &addr, addr_len);
if (rc != 0) {
- close ();
+ int err = errno;
+ if (close () != 0)
+ return -1;
+ errno = err;
return -1;
}
has_file = true;
@@ -249,7 +258,10 @@ int zmq::tcp_listener_t::set_address (const char *protocol_, const char *addr_,
// Listen for incomming connections.
rc = listen (s, backlog_);
if (rc != 0) {
- close ();
+ int err = errno;
+ if (close () != 0)
+ return -1;
+ errno = err;
return -1;
}