mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-13 10:52:56 +01:00
ZMQ_BACKLOG socket option added.
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
This commit is contained in:
parent
e8e2944f45
commit
a780833683
@ -239,6 +239,19 @@ Default value:: 100
|
||||
Applicable socket types:: all
|
||||
|
||||
|
||||
ZMQ_BACKLOG: Retrieve maximum length of the queue of pending connections
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
The 'ZMQ_RECONNECT' option shall retrieve maximum size of the
|
||||
pending connection backlog for connection-based transports. For details
|
||||
refer to your operating system documentation for the 'listen' function.
|
||||
|
||||
[horizontal]
|
||||
Option value type:: int
|
||||
Option value unit:: connections
|
||||
Default value:: 100
|
||||
Applicable socket types:: all
|
||||
|
||||
|
||||
ZMQ_FD: Retrieve file descriptor associated with the socket
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
The 'ZMQ_FD' option shall retrieve file descriptor associated with the 0MQ
|
||||
|
@ -245,6 +245,19 @@ Default value:: 100
|
||||
Applicable socket types:: all
|
||||
|
||||
|
||||
ZMQ_BACKLOG: Set maximum length of the queue of pending connections
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
The 'ZMQ_RECONNECT' option shall be set to specify maximum size of the
|
||||
pending connection backlog for connection-based transports. For details
|
||||
refer to your operating system documentation for the 'listen' function.
|
||||
|
||||
[horizontal]
|
||||
Option value type:: int
|
||||
Option value unit:: connections
|
||||
Default value:: 100
|
||||
Applicable socket types:: all
|
||||
|
||||
|
||||
RETURN VALUE
|
||||
------------
|
||||
The _zmq_setsockopt()_ function shall return zero if successful. Otherwise it
|
||||
|
@ -193,6 +193,7 @@ ZMQ_EXPORT int zmq_term (void *context);
|
||||
#define ZMQ_TYPE 16
|
||||
#define ZMQ_LINGER 17
|
||||
#define ZMQ_RECONNECT_IVL 18
|
||||
#define ZMQ_BACKLOG 19
|
||||
|
||||
/* Send/recv options. */
|
||||
#define ZMQ_NOBLOCK 1
|
||||
|
@ -85,10 +85,6 @@ namespace zmq
|
||||
// possible latencies.
|
||||
clock_precision = 1000000,
|
||||
|
||||
// Maximal number of non-accepted connections that can be held by
|
||||
// TCP listener object.
|
||||
tcp_connection_backlog = 100,
|
||||
|
||||
// Maximum transport data unit size for PGM (TPDU).
|
||||
pgm_max_tpdu = 1500
|
||||
};
|
||||
|
@ -36,6 +36,7 @@ zmq::options_t::options_t () :
|
||||
type (-1),
|
||||
linger (-1),
|
||||
reconnect_ivl (100),
|
||||
backlog (100),
|
||||
requires_in (false),
|
||||
requires_out (false),
|
||||
immediate_connect (true)
|
||||
@ -150,6 +151,15 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
|
||||
}
|
||||
reconnect_ivl = *((int*) optval_);
|
||||
return 0;
|
||||
|
||||
case ZMQ_BACKLOG:
|
||||
if (optvallen_ != sizeof (int)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
backlog = *((int*) optval_);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
errno = EINVAL;
|
||||
@ -269,6 +279,15 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
|
||||
*optvallen_ = sizeof (int);
|
||||
return 0;
|
||||
|
||||
case ZMQ_BACKLOG:
|
||||
if (*optvallen_ < sizeof (int)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
*((int*) optval_) = backlog;
|
||||
*optvallen_ = sizeof (int);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
errno = EINVAL;
|
||||
|
@ -60,6 +60,9 @@ namespace zmq
|
||||
// Interval between attempts to reconnect, in milliseconds.
|
||||
int reconnect_ivl;
|
||||
|
||||
// Maximum backlog for pending connections.
|
||||
int backlog;
|
||||
|
||||
// These options are never set by the user directly. Instead they are
|
||||
// provided by the specific socket type.
|
||||
bool requires_in;
|
||||
|
@ -42,7 +42,8 @@ zmq::tcp_listener_t::~tcp_listener_t ()
|
||||
close ();
|
||||
}
|
||||
|
||||
int zmq::tcp_listener_t::set_address (const char *protocol_, const char *addr_)
|
||||
int zmq::tcp_listener_t::set_address (const char *protocol_, const char *addr_,
|
||||
int backlog_)
|
||||
{
|
||||
// IPC protocol is not supported on Windows platform.
|
||||
if (strcmp (protocol_, "tcp") != 0 ) {
|
||||
@ -81,7 +82,7 @@ int zmq::tcp_listener_t::set_address (const char *protocol_, const char *addr_)
|
||||
}
|
||||
|
||||
// Listen for incomming connections.
|
||||
rc = listen (s, 1);
|
||||
rc = listen (s, backlog_);
|
||||
if (rc == SOCKET_ERROR) {
|
||||
wsa_error_to_errno ();
|
||||
return -1;
|
||||
@ -161,7 +162,8 @@ zmq::tcp_listener_t::~tcp_listener_t ()
|
||||
close ();
|
||||
}
|
||||
|
||||
int zmq::tcp_listener_t::set_address (const char *protocol_, const char *addr_)
|
||||
int zmq::tcp_listener_t::set_address (const char *protocol_, const char *addr_,
|
||||
int backlog_)
|
||||
{
|
||||
if (strcmp (protocol_, "tcp") == 0 ) {
|
||||
|
||||
@ -201,7 +203,7 @@ int zmq::tcp_listener_t::set_address (const char *protocol_, const char *addr_)
|
||||
}
|
||||
|
||||
// Listen for incomming connections.
|
||||
rc = listen (s, tcp_connection_backlog);
|
||||
rc = listen (s, backlog_);
|
||||
if (rc != 0) {
|
||||
close ();
|
||||
return -1;
|
||||
@ -241,7 +243,7 @@ int zmq::tcp_listener_t::set_address (const char *protocol_, const char *addr_)
|
||||
}
|
||||
|
||||
// Listen for incomming connections.
|
||||
rc = listen (s, tcp_connection_backlog);
|
||||
rc = listen (s, backlog_);
|
||||
if (rc != 0) {
|
||||
close ();
|
||||
return -1;
|
||||
|
@ -36,7 +36,8 @@ namespace zmq
|
||||
~tcp_listener_t ();
|
||||
|
||||
// Start listening on the interface.
|
||||
int set_address (const char *protocol_, const char *addr_);
|
||||
int set_address (const char *protocol_, const char *addr_,
|
||||
int backlog_);
|
||||
|
||||
// Close the listening socket.
|
||||
int close ();
|
||||
|
@ -38,7 +38,7 @@ zmq::zmq_listener_t::~zmq_listener_t ()
|
||||
|
||||
int zmq::zmq_listener_t::set_address (const char *protocol_, const char *addr_)
|
||||
{
|
||||
return tcp_listener.set_address (protocol_, addr_);
|
||||
return tcp_listener.set_address (protocol_, addr_, options.backlog);
|
||||
}
|
||||
|
||||
void zmq::zmq_listener_t::process_plug ()
|
||||
|
Loading…
Reference in New Issue
Block a user