summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@fastmq.commkdir>2009-08-29 09:41:50 +0200
committerMartin Sustrik <sustrik@fastmq.commkdir>2009-08-29 09:41:50 +0200
commit6996ef6f1a0a50a754608df9444e425d0900b143 (patch)
tree334a30e95fd68fa46e8536eece55c5fdd7dda15e /src
parentcb09c6951e2c4405318b422a1f9213af3e4b6b8a (diff)
improved error handling
Diffstat (limited to 'src')
-rw-r--r--src/ip.cpp3
-rw-r--r--src/tcp_listener.cpp9
-rw-r--r--src/tcp_listener.hpp5
-rw-r--r--src/zmq_listener.cpp4
4 files changed, 7 insertions, 14 deletions
diff --git a/src/ip.cpp b/src/ip.cpp
index 05a267e..0d14fcf 100644
--- a/src/ip.cpp
+++ b/src/ip.cpp
@@ -285,7 +285,8 @@ int zmq::resolve_ip_hostname (sockaddr_in *addr_, const char *hostname_)
// Separate the hostname.
std::string hostname (hostname_, delimiter - hostname_);
- // Resolve host name.
+ // Resolve host name. Some of the error info is lost in case of error,
+ // however, there's no way to report EAI errors via errno.
addrinfo req;
memset (&req, 0, sizeof (req));
req.ai_family = AF_INET;
diff --git a/src/tcp_listener.cpp b/src/tcp_listener.cpp
index 937618d..de62879 100644
--- a/src/tcp_listener.cpp
+++ b/src/tcp_listener.cpp
@@ -55,11 +55,10 @@ zmq::tcp_listener_t::~tcp_listener_t ()
int zmq::tcp_listener_t::set_address (const char *addr_)
{
// Convert the interface into sockaddr_in structure.
- return resolve_ip_interface (&addr, addr_);
-}
+ int rc = resolve_ip_interface (&addr, addr_);
+ if (rc != 0)
+ return rc;
-int zmq::tcp_listener_t::open ()
-{
// Create a listening socket.
s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (s == -1)
@@ -67,7 +66,7 @@ int zmq::tcp_listener_t::open ()
// Allow reusing of the address.
int flag = 1;
- int rc = setsockopt (s, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof (int));
+ rc = setsockopt (s, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof (int));
errno_assert (rc == 0);
// Set the non-blocking flag.
diff --git a/src/tcp_listener.hpp b/src/tcp_listener.hpp
index 2a8bc23..62498dc 100644
--- a/src/tcp_listener.hpp
+++ b/src/tcp_listener.hpp
@@ -35,14 +35,11 @@ namespace zmq
tcp_listener_t ();
~tcp_listener_t ();
- // Set up the address to listen on. Address is in
+ // Start listening on the interface. Address is in
// <interface-name>:<port-number> format. Interface name may be '*'
// to bind to all the interfaces.
int set_address (const char *addr_);
- // Open TCP listining socket.
- int open ();
-
// Close the listening socket.
int close ();
diff --git a/src/zmq_listener.cpp b/src/zmq_listener.cpp
index 97164c1..35e4428 100644
--- a/src/zmq_listener.cpp
+++ b/src/zmq_listener.cpp
@@ -41,10 +41,6 @@ int zmq::zmq_listener_t::set_address (const char *addr_)
void zmq::zmq_listener_t::process_plug ()
{
- // Open the listening socket.
- int rc = tcp_listener.open ();
- zmq_assert (rc == 0);
-
// Start polling for incoming connections.
handle = add_fd (tcp_listener.get_fd ());
set_pollin (handle);