MySQL 8.1.0
Source Code Documentation
socket_service_base.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2020, 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_SERVICE_BASE_H_
26#define MYSQL_HARNESS_NET_TS_IMPL_SOCKET_SERVICE_BASE_H_
27
28#include <array>
29#include <memory>
30#include <system_error>
31
32#ifdef _WIN32
33#include <WinSock2.h>
34#include <ws2tcpip.h> // addrinfo
35#else
36#include <netdb.h> // addrinfo
37#endif
38
42
43namespace net {
44namespace impl {
45namespace socket {
46
48 public:
49 virtual ~SocketServiceBase() = default;
50
52 int family, int sock_type, int protocol) const = 0;
53
56 socketpair(int family, int sock_type, int protocol) const = 0;
57
60
62 native_handle_type native_handle, unsigned long cmd,
63 void *data) const = 0;
64
67
69 native_handle_type native_handle, bool on) const = 0;
70
72 native_handle_type native_handle, int backlog) const = 0;
73
75 native_handle_type native_handle, int level, int optname,
76 const void *optval, socklen_t optlen) const = 0;
77
79 native_handle_type native_handle, int level, int optname, void *optval,
80 socklen_t *optlen) const = 0;
81
84 message_flags flags) const = 0;
85
88 message_flags flags) const = 0;
89
91 native_handle_type native_handle, const struct sockaddr *addr,
92 size_t addr_len) const = 0;
93
95 native_handle_type native_handle, const struct sockaddr *addr,
96 size_t addr_len) const = 0;
97
100 socklen_t *addr_len) const = 0;
101
102 // freebsd and linux have accept4()
103 // solaris and windows don't
106 socklen_t *addr_len, int flags = 0) const = 0;
107
110 size_t *addr_len) const = 0;
113 size_t *addr_len) const = 0;
114
115#ifdef __linux__
117 native_handle_type fd_out,
118 size_t len,
119 int flags) const = 0;
120#endif
121
123 native_handle_type fd_in, impl::file::file_handle_type fd_out, size_t len,
124 int flags) const = 0;
125
127 impl::file::file_handle_type fd_in, native_handle_type fd_out, size_t len,
128 int flags) const = 0;
129
131 wait_type wt) const = 0;
132
134 int how) const = 0;
135
136 virtual stdx::expected<
137 std::unique_ptr<struct addrinfo, void (*)(struct addrinfo *)>,
138 std::error_code>
139 getaddrinfo(const char *node, const char *service,
140 const addrinfo *hints) const = 0;
141};
142
143} // namespace socket
144} // namespace impl
145} // namespace net
146
147#endif
Definition: socket_service_base.h:47
virtual stdx::expected< void, error_type > ioctl(native_handle_type native_handle, unsigned long cmd, void *data) const =0
virtual stdx::expected< size_t, error_type > sendmsg(native_handle_type native_handle, msghdr_base &msg, message_flags flags) const =0
virtual stdx::expected< void, error_type > bind(native_handle_type native_handle, const struct sockaddr *addr, size_t addr_len) const =0
virtual stdx::expected< void, error_type > getsockopt(native_handle_type native_handle, int level, int optname, void *optval, socklen_t *optlen) const =0
virtual stdx::expected< void, error_type > getsockname(native_handle_type native_handle, struct sockaddr *addr, size_t *addr_len) const =0
virtual stdx::expected< native_handle_type, error_type > socket(int family, int sock_type, int protocol) const =0
virtual stdx::expected< void, error_type > close(native_handle_type native_handle) const =0
virtual stdx::expected< void, error_type > getpeername(native_handle_type native_handle, struct sockaddr *addr, size_t *addr_len) const =0
virtual stdx::expected< native_handle_type, error_type > accept(native_handle_type native_handle, struct sockaddr *addr, socklen_t *addr_len) const =0
virtual stdx::expected< native_handle_type, error_type > accept4(native_handle_type native_handle, struct sockaddr *addr, socklen_t *addr_len, int flags=0) const =0
virtual stdx::expected< size_t, error_type > splice_from_pipe(impl::file::file_handle_type fd_in, native_handle_type fd_out, size_t len, int flags) const =0
virtual stdx::expected< size_t, error_type > recvmsg(native_handle_type native_handle, msghdr_base &msg, message_flags flags) const =0
virtual stdx::expected< void, error_type > native_non_blocking(native_handle_type native_handle, bool on) const =0
virtual stdx::expected< std::pair< native_handle_type, native_handle_type >, error_type > socketpair(int family, int sock_type, int protocol) const =0
virtual stdx::expected< void, error_type > setsockopt(native_handle_type native_handle, int level, int optname, const void *optval, socklen_t optlen) const =0
virtual stdx::expected< bool, error_type > native_non_blocking(native_handle_type native_handle) const =0
virtual stdx::expected< size_t, error_type > splice_to_pipe(native_handle_type fd_in, impl::file::file_handle_type fd_out, size_t len, int flags) const =0
virtual stdx::expected< void, error_type > listen(native_handle_type native_handle, int backlog) const =0
virtual stdx::expected< std::unique_ptr< struct addrinfo, void(*)(struct addrinfo *)>, std::error_code > getaddrinfo(const char *node, const char *service, const addrinfo *hints) const =0
virtual stdx::expected< void, error_type > connect(native_handle_type native_handle, const struct sockaddr *addr, size_t addr_len) const =0
virtual stdx::expected< void, error_type > wait(native_handle_type fd, wait_type wt) const =0
virtual stdx::expected< void, error_type > shutdown(native_handle_type fd, int how) const =0
Definition: expected.h:943
static int flags[50]
Definition: hp_test1.cc:39
Definition: authentication.cc:35
int file_handle_type
Definition: file.h:52
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
std::error_code error_type
Definition: socket_constants.h:54
std::bitset< 31 > message_flags
Definition: socket_constants.h:63
int native_handle_type
Definition: socket_constants.h:50
Definition: buffer.h:44
native_handle_type native_handle()
Definition: process.h:55
std::conditional_t< !std::is_array< T >::value, std::unique_ptr< T, detail::Deleter< T > >, std::conditional_t< detail::is_unbounded_array_v< T >, std::unique_ptr< T, detail::Array_deleter< std::remove_extent_t< T > > >, void > > unique_ptr
The following is a common type that is returned by all the ut::make_unique (non-aligned) specializati...
Definition: ut0new.h:2437
struct sockaddr sockaddr
Definition: sock_probe_win32.h:62