diff options
author | unknown <sustrik@.(none)> | 2009-10-01 13:48:04 +0200 |
---|---|---|
committer | unknown <sustrik@.(none)> | 2009-10-01 13:48:04 +0200 |
commit | 49a9ef5fcb661827ee174415b4608e609bd0a65b (patch) | |
tree | e487422695b0b4774d42569b1fbbfa1e6a848206 /src/tcp_listener.cpp | |
parent | cc631c4c6649b0d67114db13386a949426e35dbf (diff) |
windows error handling improved
Diffstat (limited to 'src/tcp_listener.cpp')
-rw-r--r-- | src/tcp_listener.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/tcp_listener.cpp b/src/tcp_listener.cpp index 9431ccf..383aebe 100644 --- a/src/tcp_listener.cpp +++ b/src/tcp_listener.cpp @@ -48,8 +48,10 @@ int zmq::tcp_listener_t::set_address (const char *addr_) // Create a listening socket. s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); - // TODO: Convert error code to errno. - wsa_assert (s != INVALID_SOCKET); + if (s == INVALID_SOCKET) { + wsa_error_to_errno (); + return -1; + } // Allow reusing of the address. int flag = 1; @@ -65,12 +67,17 @@ int zmq::tcp_listener_t::set_address (const char *addr_) // Bind the socket to the network interface and port. rc = bind (s, (struct sockaddr*) &addr, sizeof (addr)); // TODO: Convert error code to errno. - wsa_assert (rc != SOCKET_ERROR); + if (rc == SOCKET_ERROR) { + wsa_error_to_errno (); + return -1; + } // Listen for incomming connections. rc = listen (s, 1); - // TODO: Convert error code to errno. - wsa_assert (rc != SOCKET_ERROR); + if (rc == SOCKET_ERROR) { + wsa_error_to_errno (); + return -1; + } return 0; } |