Hazelcast C++ Client
Hazelcast C++ Client Library
Loading...
Searching...
No Matches
socket_options.h
1/*
2 * Copyright (c) 2008-2025, Hazelcast, Inc. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#pragma once
17
18#include "hazelcast/util/export.h"
19
20#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
21#pragma warning(push)
22#pragma warning(disable : 4251) // for dll export
23#endif
24
25namespace hazelcast {
26namespace client {
27namespace config {
31class HAZELCAST_API socket_options
32{
33public:
37 static const int KILO_BYTE = 1024;
38
42 static const int DEFAULT_BUFFER_SIZE_BYTE = 128 * KILO_BYTE;
43
44 socket_options();
45
51 bool is_tcp_no_delay() const;
52
58 socket_options& set_tcp_no_delay(bool tcp_no_delay);
59
65 bool is_keep_alive() const;
66
73 socket_options& set_keep_alive(bool keep_alive);
74
80 bool is_reuse_address() const;
81
88 socket_options& set_reuse_address(bool reuse_address);
89
94 int get_linger_seconds() const;
95
106 socket_options& set_linger_seconds(int linger_seconds);
107
116 int get_buffer_size_in_bytes() const;
117
128 socket_options& set_buffer_size_in_bytes(int buffer_size);
129
130private:
131 // socket options
132
133 bool tcp_no_delay_;
134
135 bool keep_alive_;
136
137 bool reuse_address_;
138
139 int linger_seconds_;
140
141 int buffer_size_;
142};
143
144} // namespace config
145} // namespace client
146} // namespace hazelcast
147
148#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
149#pragma warning(pop)
150#endif
socket_options & set_tcp_no_delay(bool tcp_no_delay)
Enable/disable TCP_NODELAY socket option.
Definition config.cpp:529
socket_options & set_reuse_address(bool reuse_address)
Enable/disable the SO_REUSEADDR socket option.
Definition config.cpp:555
socket_options & set_linger_seconds(int linger_seconds)
Enable/disable SO_LINGER with the specified linger time in seconds.
Definition config.cpp:568
static const int DEFAULT_BUFFER_SIZE_BYTE
default buffer size of Bytes
bool is_keep_alive() const
SO_KEEPALIVE socket option.
Definition config.cpp:536
socket_options & set_keep_alive(bool keep_alive)
Enable/disable SO_KEEPALIVE socket option.
Definition config.cpp:542
bool is_reuse_address() const
SO_REUSEADDR socket option.
Definition config.cpp:549
bool is_tcp_no_delay() const
TCP_NODELAY socket option.
Definition config.cpp:523
int get_buffer_size_in_bytes() const
If set to 0 or less, then it is not set on the socket.
Definition config.cpp:575
socket_options & set_buffer_size_in_bytes(int buffer_size)
If set to 0 or less, then it is not set on the socket.
Definition config.cpp:581
static const int KILO_BYTE
constant for kilobyte
int get_linger_seconds() const
Gets SO_LINGER with the specified linger time in seconds.
Definition config.cpp:562