MySQL 8.3.0
Source Code Documentation
socket_constants.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2019, 2023, 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 also distributed 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 included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23*/
24
25#ifndef MYSQL_HARNESS_NET_TS_IMPL_SOCKET_CONSTANTS_H_
26#define MYSQL_HARNESS_NET_TS_IMPL_SOCKET_CONSTANTS_H_
27
28#include <bitset>
29#include <system_error>
30
31#ifdef _WIN32
32#include <WinSock2.h>
33#include <Windows.h>
34#else
35#include <poll.h> // POLLIN, ...
36#include <sys/socket.h> // MSG_...
37#endif
38
39namespace net {
40namespace impl {
41namespace socket {
42
43#ifdef _WIN32
44constexpr const int kSocketError{SOCKET_ERROR};
45using native_handle_type = SOCKET;
47using socklen_t = int;
48#else
49constexpr const int kSocketError{-1};
52#endif
53
54using error_type = std::error_code;
55#ifdef _WIN32
56using msghdr_base = ::WSAMSG;
57using iovec_base = ::WSABUF;
58#else
59using msghdr_base = ::msghdr;
60using iovec_base = ::iovec;
61#endif
62
63using message_flags = std::bitset<31>;
64
65static constexpr message_flags message_peek = MSG_PEEK;
66static constexpr message_flags message_out_of_band = MSG_OOB;
67static constexpr message_flags message_do_not_route = MSG_DONTROUTE;
68#ifdef MSG_FASTOPEN
69// linux
70static constexpr message_flags message_fast_open = MSG_FASTOPEN;
71#endif
72#ifdef MSG_ZEROCOPY
73// linux
74static constexpr message_flags message_zero_copy = MSG_ZEROCOPY;
75#endif
76#ifdef MSG_ERRQUEUE
77// linux
78static constexpr message_flags message_error_queue = MSG_ERRQUEUE;
79#endif
80#ifdef _WIN32
81static constexpr message_flags message_partial = MSG_PARTIAL;
82static constexpr message_flags message_waitall = MSG_WAITALL;
83#endif
84
85enum class wait_type {
86 wait_read = POLLIN,
87 wait_write = POLLOUT,
88 wait_error = POLLERR | POLLHUP,
89};
90
91} // namespace socket
92} // namespace impl
93} // namespace net
94
95#endif
#define INVALID_SOCKET
Definition: my_io.h:189
Definition: authentication.cc:35
stdx::expected< native_handle_type, error_type > socket(int family, int sock_type, int protocol)
Definition: socket.h:62
wait_type
Definition: socket_constants.h:85
::msghdr msghdr_base
Definition: socket_constants.h:59
::iovec iovec_base
Definition: socket_constants.h:60
static constexpr message_flags message_out_of_band
Definition: socket_constants.h:66
static constexpr message_flags message_do_not_route
Definition: socket_constants.h:67
std::error_code error_type
Definition: socket_constants.h:54
std::bitset< 31 > message_flags
Definition: socket_constants.h:63
static constexpr message_flags message_peek
Definition: socket_constants.h:65
constexpr const int kSocketError
Definition: socket_constants.h:49
int native_handle_type
Definition: socket_constants.h:50
constexpr const native_handle_type kInvalidSocket
Definition: socket_constants.h:51
Definition: buffer.h:44
#define SOCKET_ERROR
Definition: x_platform.h:283