options.hpp 4.1 KB
Newer Older
1
/*
Martin Sustrik's avatar
Martin Sustrik committed
2
    Copyright (c) 2009-2011 250bpm s.r.o.
3
    Copyright (c) 2007-2009 iMatix Corporation
4
    Copyright (c) 2011 VMware, Inc.
5
    Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
6 7 8 9

    This file is part of 0MQ.

    0MQ is free software; you can redistribute it and/or modify it under
10
    the terms of the GNU Lesser General Public License as published by
11 12 13 14 15 16
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    0MQ is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
    GNU Lesser General Public License for more details.
18

19
    You should have received a copy of the GNU Lesser General Public License
20 21 22 23 24 25
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __ZMQ_OPTIONS_HPP_INCLUDED__
#define __ZMQ_OPTIONS_HPP_INCLUDED__

26
#include <string>
27
#include <vector>
28

29
#include "stddef.h"
unknown's avatar
unknown committed
30
#include "stdint.hpp"
31
#include "tcp_address.hpp"
32
#include "../include/zmq.h"
unknown's avatar
unknown committed
33

34 35 36 37 38 39 40
namespace zmq
{

    struct options_t
    {
        options_t ();

41
        int setsockopt (int option_, const void *optval_, size_t optvallen_);
42
        int getsockopt (int option_, void *optval_, size_t *optvallen_);
43

44 45 46
        //  High-water marks for message pipes.
        int sndhwm;
        int rcvhwm;
47

48
        //  I/O thread affinity.
49
        uint64_t affinity;
malosek's avatar
malosek committed
50

51 52 53
        //  Socket identity
        unsigned char identity_size;
        unsigned char identity [256];
54

55
        // Last socket endpoint resolved URI
56
        std::string last_endpoint;
57

58
        //  Maximum tranfer rate [kb/s]. Default 100kb/s.
59
        int rate;
malosek's avatar
malosek committed
60

61
        //  Reliability time interval [ms]. Default 10 seconds.
62
        int recovery_ivl;
63

64 65 66
        // Sets the time-to-live field in every multicast packet sent.
        int multicast_hops;

67 68 69
        // SO_SNDBUF and SO_RCVBUF to be passed to underlying transport sockets.
        int sndbuf;
        int rcvbuf;
70

71 72 73
        //  Socket type.
        int type;

74 75 76
        //  Linger time, in milliseconds.
        int linger;

77 78
        //  Minimum interval between attempts to reconnect, in milliseconds.
        //  Default 100ms
79
        int reconnect_ivl;
80

81 82 83
        //  Maximum interval between attempts to reconnect, in milliseconds.
        //  Default 0 (unused)
        int reconnect_ivl_max;
84

85 86 87
        //  Maximum backlog for pending connections.
        int backlog;

88 89 90
        //  Maximal size of message to handle.
        int64_t maxmsgsize;

91 92 93 94
        // The timeout for send/recv operations for this socket.
        int rcvtimeo;
        int sndtimeo;

Steven McCoy's avatar
Steven McCoy committed
95 96 97 98
        //  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;
99 100 101 102
        
        //  If 1, connecting pipes are not attached immediately, meaning a send()
        //  on a socket with only connecting pipes would block
        int delay_attach_on_connect;
Steven McCoy's avatar
Steven McCoy committed
103

104 105 106 107 108 109 110
        //  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;

        //  If true, socket reads all the messages from the pipe and delivers
        //  them to the user when the peer terminates.
        bool delay_on_disconnect;
111 112 113

        //  If 1, (X)SUB socket should filter the messages. If 0, it should not.
        bool filter;
114

115
        //  If true, the identity message is forwarded to the socket.
116
        bool recv_identity;
Martin Hurton's avatar
Martin Hurton committed
117

118 119
        // if true, router socket accepts non-zmq tcp connections
        bool raw_sock;
120 121 122 123 124 125 126 127

        //  TCP keep-alive settings.
        //  Defaults to -1 = do not change socket options
        int tcp_keepalive;
        int tcp_keepalive_cnt;
        int tcp_keepalive_idle;
        int tcp_keepalive_intvl;

128 129 130 131
        // TCP accept() filters
        typedef std::vector <tcp_address_mask_t> tcp_accept_filters_t;
        tcp_accept_filters_t tcp_accept_filters;

132 133
        //  ID of the socket.
        int socket_id;
134 135 136 137 138
    };

}

#endif