Commit e5832763 authored by Simon Giesecke's avatar Simon Giesecke Committed by Simon Giesecke

Problem: unnecessary platform-specific code parts around socklen_t

Solution: use zmq_socklen_t
parent c215235f
...@@ -49,12 +49,10 @@ const struct sockaddr *zmq::ip_addr_t::as_sockaddr () const ...@@ -49,12 +49,10 @@ const struct sockaddr *zmq::ip_addr_t::as_sockaddr () const
return &generic; return &generic;
} }
socklen_t zmq::ip_addr_t::sockaddr_len () const zmq::zmq_socklen_t zmq::ip_addr_t::sockaddr_len () const
{ {
if (family () == AF_INET6) { return static_cast<zmq_socklen_t> (family () == AF_INET6 ? sizeof (ipv6)
return sizeof (ipv6); : sizeof (ipv4));
}
return sizeof (ipv4);
} }
void zmq::ip_addr_t::set_port (uint16_t port_) void zmq::ip_addr_t::set_port (uint16_t port_)
......
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
#include <netinet/in.h> #include <netinet/in.h>
#endif #endif
#include "address.hpp"
namespace zmq namespace zmq
{ {
union ip_addr_t union ip_addr_t
...@@ -48,7 +50,7 @@ union ip_addr_t ...@@ -48,7 +50,7 @@ union ip_addr_t
uint16_t port () const; uint16_t port () const;
const struct sockaddr *as_sockaddr () const; const struct sockaddr *as_sockaddr () const;
socklen_t sockaddr_len () const; zmq_socklen_t sockaddr_len () const;
void set_port (uint16_t); void set_port (uint16_t);
......
...@@ -144,11 +144,7 @@ zmq::fd_t zmq::ipc_connecter_t::connect () ...@@ -144,11 +144,7 @@ zmq::fd_t zmq::ipc_connecter_t::connect ()
// Following code should handle both Berkeley-derived socket // Following code should handle both Berkeley-derived socket
// implementations and Solaris. // implementations and Solaris.
int err = 0; int err = 0;
#if defined ZMQ_HAVE_HPUX zmq_socklen_t len = static_cast<zmq_socklen_t> (sizeof (err));
int len = sizeof (err);
#else
socklen_t len = sizeof (err);
#endif
int rc = getsockopt (_s, SOL_SOCKET, SO_ERROR, int rc = getsockopt (_s, SOL_SOCKET, SO_ERROR,
reinterpret_cast<char *> (&err), &len); reinterpret_cast<char *> (&err), &len);
if (rc == -1) { if (rc == -1) {
......
...@@ -198,7 +198,8 @@ void zmq::udp_engine_t::plug (io_thread_t *io_thread_, session_base_t *session_) ...@@ -198,7 +198,8 @@ void zmq::udp_engine_t::plug (io_thread_t *io_thread_, session_base_t *session_)
} else { } else {
/// XXX fixme ? /// XXX fixme ?
_out_address = reinterpret_cast<sockaddr *> (&_raw_address); _out_address = reinterpret_cast<sockaddr *> (&_raw_address);
_out_address_len = sizeof (sockaddr_in); _out_address_len =
static_cast<zmq_socklen_t> (sizeof (sockaddr_in));
} }
set_pollout (_handle); set_pollout (_handle);
...@@ -437,11 +438,11 @@ void zmq::udp_engine_t::out_event () ...@@ -437,11 +438,11 @@ void zmq::udp_engine_t::out_event ()
#ifdef ZMQ_HAVE_WINDOWS #ifdef ZMQ_HAVE_WINDOWS
rc = sendto (_fd, _out_buffer, static_cast<int> (size), 0, _out_address, rc = sendto (_fd, _out_buffer, static_cast<int> (size), 0, _out_address,
static_cast<int> (_out_address_len)); _out_address_len);
wsa_assert (rc != SOCKET_ERROR); wsa_assert (rc != SOCKET_ERROR);
#elif defined ZMQ_HAVE_VXWORKS #elif defined ZMQ_HAVE_VXWORKS
rc = sendto (_fd, reinterpret_cast<caddr_t> (_out_buffer), size, 0, rc = sendto (_fd, reinterpret_cast<caddr_t> (_out_buffer), size, 0,
(sockaddr *) _out_address, (int) _out_address_len); (sockaddr *) _out_address, _out_address_len);
errno_assert (rc != -1); errno_assert (rc != -1);
#else #else
rc = sendto (_fd, _out_buffer, size, 0, _out_address, _out_address_len); rc = sendto (_fd, _out_buffer, size, 0, _out_address, _out_address_len);
......
...@@ -62,7 +62,7 @@ class udp_engine_t : public io_object_t, public i_engine ...@@ -62,7 +62,7 @@ class udp_engine_t : public io_object_t, public i_engine
sockaddr_in _raw_address; sockaddr_in _raw_address;
const struct sockaddr *_out_address; const struct sockaddr *_out_address;
socklen_t _out_address_len; zmq_socklen_t _out_address_len;
char _out_buffer[MAX_UDP_MSG]; char _out_buffer[MAX_UDP_MSG];
char _in_buffer[MAX_UDP_MSG]; char _in_buffer[MAX_UDP_MSG];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment