summaryrefslogtreecommitdiff
path: root/src/tcp_engine.cpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2011-07-29 09:37:43 +0200
committerMartin Sustrik <sustrik@250bpm.com>2011-07-29 09:37:43 +0200
commitd5f3628ad08849a0c978f7d23dc678133ed33c42 (patch)
treede82260f962d25b4762497af8358bd6182feefb4 /src/tcp_engine.cpp
parentf63db009a1e1baf9f1fe7dae39901c7449c66131 (diff)
Different connecters simplified
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/tcp_engine.cpp')
-rw-r--r--src/tcp_engine.cpp27
1 files changed, 6 insertions, 21 deletions
diff --git a/src/tcp_engine.cpp b/src/tcp_engine.cpp
index f940b84..f938d71 100644
--- a/src/tcp_engine.cpp
+++ b/src/tcp_engine.cpp
@@ -39,6 +39,7 @@
#include "session.hpp"
#include "config.hpp"
#include "err.hpp"
+#include "ip.hpp"
zmq::tcp_engine_t::tcp_engine_t (fd_t fd_, const options_t &options_) :
s (fd_),
@@ -53,28 +54,12 @@ zmq::tcp_engine_t::tcp_engine_t (fd_t fd_, const options_t &options_) :
options (options_),
plugged (false)
{
- int rc;
-
- // Set the socket to the non-blocking mode.
-#ifdef ZMQ_HAVE_WINDOWS
- u_long nonblock = 1;
- rc = ioctlsocket (s, FIONBIO, &nonblock);
- wsa_assert (rc != SOCKET_ERROR);
-#elif ZMQ_HAVE_OPENVMS
- int nonblock = 1;
- rc = ioctl (s, FIONBIO, &nonblock);
- errno_assert (rc != -1);
-#else
- int flags = fcntl (s, F_GETFL, 0);
- if (flags == -1)
- flags = 0;
- rc = fcntl (s, F_SETFL, flags | O_NONBLOCK);
- errno_assert (rc != -1);
-#endif
+ // Get the socket into non-blocking mode.
+ unblock_socket (s);
// Set the socket buffer limits for the underlying socket.
if (options.sndbuf) {
- rc = setsockopt (s, SOL_SOCKET, SO_SNDBUF,
+ int rc = setsockopt (s, SOL_SOCKET, SO_SNDBUF,
(char*) &options.sndbuf, sizeof (int));
#ifdef ZMQ_HAVE_WINDOWS
wsa_assert (rc != SOCKET_ERROR);
@@ -83,7 +68,7 @@ zmq::tcp_engine_t::tcp_engine_t (fd_t fd_, const options_t &options_) :
#endif
}
if (options.rcvbuf) {
- rc = setsockopt (s, SOL_SOCKET, SO_RCVBUF,
+ int rc = setsockopt (s, SOL_SOCKET, SO_RCVBUF,
(char*) &options.rcvbuf, sizeof (int));
#ifdef ZMQ_HAVE_WINDOWS
wsa_assert (rc != SOCKET_ERROR);
@@ -96,7 +81,7 @@ zmq::tcp_engine_t::tcp_engine_t (fd_t fd_, const options_t &options_) :
// Make sure that SIGPIPE signal is not generated when writing to a
// connection that was already closed by the peer.
int set = 1;
- rc = setsockopt (s, SOL_SOCKET, SO_NOSIGPIPE, &set, sizeof (int));
+ int rc = setsockopt (s, SOL_SOCKET, SO_NOSIGPIPE, &set, sizeof (int));
errno_assert (rc == 0);
#endif
}