options.hpp 3.93 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
namespace zmq
{
    struct options_t
    {
        options_t ();

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

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

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

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

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

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

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

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

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

70 71 72
        //  Socket type.
        int type;

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

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

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

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

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

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

Pieter Hintjens's avatar
Pieter Hintjens committed
94 95
        //  If true, IPv6 is enabled (as well as IPv4)
        bool ipv6;
96 97 98 99
        
        //  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
100

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

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

112
        //  If true, the identity message is forwarded to the socket.
113
        bool recv_identity;
Martin Hurton's avatar
Martin Hurton committed
114

115 116
        // if true, router socket accepts non-zmq tcp connections
        bool raw_sock;
117 118 119 120 121 122 123 124

        //  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;

125 126 127 128
        // TCP accept() filters
        typedef std::vector <tcp_address_mask_t> tcp_accept_filters_t;
        tcp_accept_filters_t tcp_accept_filters;

129 130
        //  ID of the socket.
        int socket_id;
131 132 133 134 135
    };

}

#endif