MySQL 9.1.0
Source Code Documentation
socket_constants.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2019, 2024, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#ifndef MYSQL_HARNESS_NET_TS_IMPL_SOCKET_CONSTANTS_H_
27#define MYSQL_HARNESS_NET_TS_IMPL_SOCKET_CONSTANTS_H_
28
29#include <bitset>
30#include <system_error>
31
32#ifdef _WIN32
33#include <WinSock2.h>
34#include <Windows.h>
35#else
36#include <poll.h> // POLLIN, ...
37#include <sys/socket.h> // MSG_...
38#endif
39
40namespace net {
41namespace impl {
42namespace socket {
43
44#ifdef _WIN32
45constexpr const int kSocketError{SOCKET_ERROR};
46using native_handle_type = SOCKET;
48using socklen_t = int;
49#else
50constexpr const int kSocketError{-1};
53#endif
54
55using error_type = std::error_code;
56#ifdef _WIN32
57using msghdr_base = ::WSAMSG;
58using iovec_base = ::WSABUF;
59#else
60using msghdr_base = ::msghdr;
61using iovec_base = ::iovec;
62#endif
63
64using message_flags = std::bitset<31>;
65
66static constexpr message_flags message_peek = MSG_PEEK;
67static constexpr message_flags message_out_of_band = MSG_OOB;
68static constexpr message_flags message_do_not_route = MSG_DONTROUTE;
69#ifdef MSG_FASTOPEN
70// linux
71static constexpr message_flags message_fast_open = MSG_FASTOPEN;
72#endif
73#ifdef MSG_ZEROCOPY
74// linux
75static constexpr message_flags message_zero_copy = MSG_ZEROCOPY;
76#endif
77#ifdef MSG_ERRQUEUE
78// linux
79static constexpr message_flags message_error_queue = MSG_ERRQUEUE;
80#endif
81#ifdef _WIN32
82static constexpr message_flags message_partial = MSG_PARTIAL;
83static constexpr message_flags message_waitall = MSG_WAITALL;
84#endif
85
86enum class wait_type {
87 wait_read = POLLIN,
88 wait_write = POLLOUT,
89 wait_error = POLLERR | POLLHUP,
90};
91
92} // namespace socket
93} // namespace impl
94} // namespace net
95
96#endif
#define INVALID_SOCKET
Definition: my_io.h:190
Definition: http_server_component.cc:34
stdx::expected< native_handle_type, error_type > socket(int family, int sock_type, int protocol)
Definition: socket.h:63
wait_type
Definition: socket_constants.h:86
::msghdr msghdr_base
Definition: socket_constants.h:60
::iovec iovec_base
Definition: socket_constants.h:61
static constexpr message_flags message_out_of_band
Definition: socket_constants.h:67
static constexpr message_flags message_do_not_route
Definition: socket_constants.h:68
std::error_code error_type
Definition: socket_constants.h:55
std::bitset< 31 > message_flags
Definition: socket_constants.h:64
static constexpr message_flags message_peek
Definition: socket_constants.h:66
constexpr const int kSocketError
Definition: socket_constants.h:50
int native_handle_type
Definition: socket_constants.h:51
constexpr const native_handle_type kInvalidSocket
Definition: socket_constants.h:52
Definition: buffer.h:45
#define SOCKET_ERROR
Definition: x_platform.h:284