mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-27 15:41:05 +08:00
ZMQ_IPV4ONLY option added
At this point option exists, is documented and can be set, however, it has no effect. Signed-off-by: Steven McCoy <steven.mccoy@miru.hk> Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
This commit is contained in:
parent
8378180cbb
commit
784041f5b9
@ -329,6 +329,21 @@ Default value:: -1 (infinite)
|
||||
Applicable socket types:: all
|
||||
|
||||
|
||||
ZMQ_IPV4ONLY: Retrieve IPv4-only socket override status
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Retrieve the underlying native socket type. A value of `1` will use IPv4
|
||||
sockets, while the default value of `0` will use IPv6 sockets. An IPv6 socket
|
||||
lets applications connect to and accept connections from both IPv4 and IPv6
|
||||
hosts.
|
||||
|
||||
[horizontal]
|
||||
Option value type:: int
|
||||
Option value unit:: boolean
|
||||
Default value:: 1 (true)
|
||||
Applicable socket types:: all, when using TCP transports.
|
||||
|
||||
|
||||
ZMQ_FD: Retrieve file descriptor associated with the socket
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
The 'ZMQ_FD' option shall retrieve the file descriptor associated with the
|
||||
|
@ -321,6 +321,20 @@ Default value:: -1 (infinite)
|
||||
Applicable socket types:: all
|
||||
|
||||
|
||||
ZMQ_IPV4ONLY: Use IPv4-only sockets
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Sets the underlying native socket type. A value of `1` will use IPv4 sockets,
|
||||
while the default value of `0` will use IPv6 sockets. An IPv6 socket lets
|
||||
applications connect to and accept connections from both IPv4 and IPv6 hosts.
|
||||
|
||||
[horizontal]
|
||||
Option value type:: int
|
||||
Option value unit:: boolean
|
||||
Default value:: 1 (true)
|
||||
Applicable socket types:: all, when using TCP transports.
|
||||
|
||||
|
||||
RETURN VALUE
|
||||
------------
|
||||
The _zmq_setsockopt()_ function shall return zero if successful. Otherwise it
|
||||
|
@ -31,13 +31,13 @@ colon and the TCP port number to use.
|
||||
An 'interface' may be specified by either of the following:
|
||||
|
||||
* The wild-card `*`, meaning all available interfaces.
|
||||
* The primary IPv4 address assigned to the interface, in its numeric
|
||||
* The primary IPv4 or IPv6 address assigned to the interface, in its numeric
|
||||
representation.
|
||||
* The interface name as defined by the operating system.
|
||||
|
||||
NOTE: Interface names are not standardised in any way and should be assumed to
|
||||
be arbitrary and platform dependent. On Win32 platforms no short interface
|
||||
names exist, thus only the primary IPv4 address may be used to specify an
|
||||
names exist, thus only the primary IP address may be used to specify an
|
||||
'interface'.
|
||||
|
||||
Connecting a socket
|
||||
@ -49,7 +49,7 @@ a colon and the TCP port number to use.
|
||||
A 'peer address' may be specified by either of the following:
|
||||
|
||||
* The DNS name of the peer.
|
||||
* The IPv4 address of the peer, in it's numeric representation.
|
||||
* The IPv4 or IPv6 address of the peer, in it's numeric representation.
|
||||
|
||||
|
||||
WIRE FORMAT
|
||||
|
@ -185,7 +185,8 @@ ZMQ_EXPORT int zmq_term (void *context);
|
||||
#define ZMQ_SNDTIMEO 28
|
||||
#define ZMQ_RCVLABEL 29
|
||||
#define ZMQ_RCVCMD 30
|
||||
|
||||
#define ZMQ_IPV4ONLY 31
|
||||
|
||||
/* Send/recv options. */
|
||||
#define ZMQ_DONTWAIT 1
|
||||
#define ZMQ_SNDMORE 2
|
||||
|
@ -40,6 +40,7 @@ zmq::options_t::options_t () :
|
||||
maxmsgsize (-1),
|
||||
rcvtimeo (-1),
|
||||
sndtimeo (-1),
|
||||
ipv4only (1),
|
||||
delay_on_close (true),
|
||||
delay_on_disconnect (true),
|
||||
filter (false)
|
||||
@ -179,6 +180,21 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
|
||||
sndtimeo = *((int*) optval_);
|
||||
return 0;
|
||||
|
||||
case ZMQ_IPV4ONLY:
|
||||
{
|
||||
if (optvallen_ != sizeof (int)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
int val = *((int*) optval_);
|
||||
if (val != 0 && val != 1) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
ipv4only = val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
errno = EINVAL;
|
||||
@ -333,6 +349,15 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
|
||||
*optvallen_ = sizeof (int);
|
||||
return 0;
|
||||
|
||||
case ZMQ_IPV4ONLY:
|
||||
if (*optvallen_ < sizeof (int)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
*((int*) optval_) = ipv4only;
|
||||
*optvallen_ = sizeof (int);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
errno = EINVAL;
|
||||
|
@ -78,6 +78,11 @@ namespace zmq
|
||||
int rcvtimeo;
|
||||
int sndtimeo;
|
||||
|
||||
// If 1, indicates the use of IPv4 sockets only, it will not be
|
||||
// possible to communicate with IPv6-only hosts. If 0, the socket can
|
||||
// connect to and accept connections from both IPv4 and IPv6 hosts.
|
||||
int ipv4only;
|
||||
|
||||
// If true, session reads all the pending messages from the pipe and
|
||||
// sends them to the network when socket is closed.
|
||||
bool delay_on_close;
|
||||
|
Loading…
x
Reference in New Issue
Block a user