2010-01-05 08:29:35 +01:00
|
|
|
.TH zmq_setsockopt 3 "" "(c)2007-2010 iMatix Corporation" "0MQ User Manuals"
|
2009-11-22 08:47:06 +01:00
|
|
|
.SH NAME
|
|
|
|
zmq_setsockopt \- sets a specified option on a 0MQ socket
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.B int zmq_setsockopt (void *s, int option, const void *optval, size_t optvallen);
|
|
|
|
.SH DESCRIPTION
|
2009-11-22 16:51:21 +01:00
|
|
|
Sets an option on the socket.
|
|
|
|
.IR option
|
|
|
|
argument specifies the option from the list below.
|
|
|
|
.IR optval
|
|
|
|
is a pointer to the value to set,
|
|
|
|
.IR optvallen
|
|
|
|
is the size of the value in bytes.
|
|
|
|
|
|
|
|
.IP "\fBZMQ_HWM\fP"
|
|
|
|
High watermark for the message pipes associated with the socket. The water
|
|
|
|
mark cannot be exceeded. If the messages don't fit into the pipe emergency
|
|
|
|
mechanisms of the particular socket type are used (block, drop etc.) If HWM
|
|
|
|
is set to zero, there are no limits for the content of the pipe.
|
2009-12-10 09:47:24 +01:00
|
|
|
|
2009-11-22 16:51:21 +01:00
|
|
|
Type: int64_t Unit: bytes Default: 0
|
|
|
|
|
|
|
|
.IP "\fBZMQ_LWM\fP"
|
|
|
|
Low watermark makes sense only if high watermark is defined (i.e. is non-zero).
|
|
|
|
When the emergency state is reached when messages overflow the pipe, the
|
|
|
|
emergency lasts till the size of the pipe decreases to low watermark.
|
|
|
|
At that point normal state is resumed.
|
2009-12-10 09:47:24 +01:00
|
|
|
|
2009-11-22 16:51:21 +01:00
|
|
|
Type: int64_t Unit: bytes Default: 0
|
|
|
|
|
|
|
|
.IP "\fBZMQ_SWAP\fP"
|
|
|
|
Swap allows the pipe to exceed high watermark. However, the data are written
|
|
|
|
to the disk rather than held in the memory. Until high watermark is
|
|
|
|
exceeded there is no disk activity involved though. The value of the option
|
|
|
|
defines maximal size of the swap file.
|
2009-12-10 09:47:24 +01:00
|
|
|
|
2009-11-22 16:51:21 +01:00
|
|
|
Type: int64_t Unit: bytes Default: 0
|
|
|
|
|
|
|
|
.IP "\fBZMQ_AFFINITY\fP"
|
|
|
|
Affinity defines which threads in the thread pool will be used to handle
|
|
|
|
newly created sockets. This way you can dedicate some of the threads (CPUs)
|
|
|
|
to a specific work. Value of 0 means no affinity. Work is distributed
|
|
|
|
fairly among the threads in the thread pool. For non-zero values, the lowest
|
|
|
|
bit corresponds to the thread 1, second lowest bit to the thread 2 etc.
|
|
|
|
Thus, value of 3 means that from now on newly created sockets will handle
|
|
|
|
I/O activity exclusively using threads no. 1 and 2.
|
2009-12-10 09:47:24 +01:00
|
|
|
|
2009-11-22 16:51:21 +01:00
|
|
|
Type: int64_t Unit: N/A (bitmap) Default: 0
|
|
|
|
|
|
|
|
.IP "\fBZMQ_IDENTITY\fP"
|
|
|
|
Identity of the socket. Identity is important when restarting applications.
|
|
|
|
If the socket has no identity, each run of the application is completely
|
|
|
|
separated from other runs. However, with identity application reconnects to
|
|
|
|
existing infrastructure left by the previous run. Thus it may receive
|
|
|
|
messages that were sent in the meantime, it shares pipe limits with the
|
|
|
|
previous run etc.
|
2009-12-10 09:47:24 +01:00
|
|
|
|
2009-11-22 16:51:21 +01:00
|
|
|
Type: string Unit: N/A Default: NULL
|
|
|
|
|
|
|
|
.IP "\fBZMQ_SUBSCRIBE\fP"
|
|
|
|
Applicable only to ZMQ_SUB socket type. It establishes new message filter.
|
|
|
|
When ZMQ_SUB socket is created all the incoming messages are filtered out.
|
|
|
|
This option allows you to subscribe for all messages ("*"), messages with
|
|
|
|
specific topic ("x.y.z") and/or messages with specific topic prefix
|
|
|
|
("x.y.*"). Topic is one-byte-size-prefixed string located at
|
|
|
|
the very beginning of the message. Multiple filters can be attached to
|
|
|
|
a single 'sub' socket. In that case message passes if it matches at least
|
|
|
|
one of the filters.
|
2009-12-10 09:47:24 +01:00
|
|
|
|
2009-11-22 16:51:21 +01:00
|
|
|
Type: string Unit: N/A Default: N/A
|
|
|
|
|
|
|
|
.IP "\fBZMQ_UNSUBSCRIBE\fP"
|
|
|
|
Applicable only to ZMQ_SUB socket type. Removes existing message filter.
|
|
|
|
The filter specified must match the string passed to ZMQ_SUBSCRIBE options
|
|
|
|
exactly. If there were several instances of the same filter created,
|
|
|
|
this options removes only one of them, leaving the rest in place
|
|
|
|
and functional.
|
2009-12-10 09:47:24 +01:00
|
|
|
|
2009-11-22 16:51:21 +01:00
|
|
|
Type: string Unit: N/A Default: N/A
|
|
|
|
|
|
|
|
.IP "\fBZMQ_RATE\fP"
|
|
|
|
This option applies only to sending side of multicast transports (pgm & udp).
|
|
|
|
It specifies maximal outgoing data rate that an individual sender socket
|
|
|
|
can send.
|
2009-12-10 09:47:24 +01:00
|
|
|
|
2009-11-22 16:51:21 +01:00
|
|
|
Type: uint64_t Unit: kilobits/second Default: 100
|
|
|
|
|
|
|
|
.IP "\fBZMQ_RECOVERY_IVL\fP"
|
|
|
|
This option applies only to multicast transports (pgm & udp). It specifies
|
|
|
|
how long can the receiver socket survive when the sender is inaccessible.
|
|
|
|
Keep in mind that large recovery intervals at high data rates result in
|
|
|
|
very large recovery buffers, meaning that you can easily overload your box
|
|
|
|
by setting say 1 minute recovery interval at 1Gb/s rate (requires
|
|
|
|
7GB in-memory buffer).
|
2009-12-10 09:47:24 +01:00
|
|
|
|
2009-11-22 16:51:21 +01:00
|
|
|
Type: uint64_t Unit: seconds Default: 10
|
|
|
|
|
|
|
|
.IP "\fBZMQ_MCAST_LOOP\fP"
|
|
|
|
This option applies only to multicast transports (pgm & udp). Value of 1
|
|
|
|
means that the mutlicast packets can be received on the box they were sent
|
|
|
|
from. Setting the value to 0 disables the loopback functionality which
|
|
|
|
can have negative impact on the performance. If possible, disable
|
|
|
|
the loopback in production environments.
|
2009-12-10 09:47:24 +01:00
|
|
|
|
2009-11-22 16:51:21 +01:00
|
|
|
Type: uint64_t Unit: N/A (boolean value) Default: 1
|
|
|
|
|
2009-12-10 09:47:24 +01:00
|
|
|
.IP "\fBZMQ_SNDBUF\fP"
|
|
|
|
Sets the underlying kernel transmit buffer size to the specified size. See
|
|
|
|
.IR SO_SNDBUF
|
|
|
|
POSIX socket option. Value of zero means leaving the OS default unchanged.
|
|
|
|
|
|
|
|
Type: uint64_t Unit: bytes Default: 0
|
|
|
|
|
|
|
|
.IP "\fBZMQ_RCVBUF\fP"
|
|
|
|
Sets the underlying kernel receive buffer size to the specified size. See
|
|
|
|
.IR SO_RCVBUF
|
|
|
|
POSIX socket option. Value of zero means leaving the OS default unchanged.
|
|
|
|
|
|
|
|
Type: uint64_t Unit: bytes Default: 0
|
|
|
|
|
2009-11-22 08:47:06 +01:00
|
|
|
.SH RETURN VALUE
|
2009-11-22 16:51:21 +01:00
|
|
|
In case of success the function returns zero. Otherwise it returns -1 and
|
|
|
|
sets
|
|
|
|
.IR errno
|
|
|
|
to the appropriate value.
|
2009-11-22 08:47:06 +01:00
|
|
|
.SH ERRORS
|
2009-11-22 16:51:21 +01:00
|
|
|
.IP "\fBEINVAL\fP"
|
|
|
|
unknown option, a value with incorrect length or invalid value.
|
2009-11-22 08:47:06 +01:00
|
|
|
.SH EXAMPLE
|
2009-11-22 16:51:21 +01:00
|
|
|
.nf
|
|
|
|
int rc = zmq_setsockopt (s, ZMQ_SUBSCRIBE, "*", 1);
|
|
|
|
assert (rc == 0);
|
|
|
|
.fi
|
2009-11-22 08:47:06 +01:00
|
|
|
.SH SEE ALSO
|
2009-11-22 16:51:21 +01:00
|
|
|
.BR zmq_socket (3)
|
|
|
|
.BR zmq (7)
|
|
|
|
|
2009-11-22 08:47:06 +01:00
|
|
|
.SH AUTHOR
|
|
|
|
Martin Sustrik <sustrik at 250bpm dot com>
|