MySQL 8.0.40
Source Code Documentation
socket_service_base.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2020, 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_SERVICE_BASE_H_
27#define MYSQL_HARNESS_NET_TS_IMPL_SOCKET_SERVICE_BASE_H_
28
29#include <array>
30#include <memory>
31#include <system_error>
32
33#ifdef _WIN32
34#include <WinSock2.h>
35#include <ws2tcpip.h> // addrinfo
36#else
37#include <netdb.h> // addrinfo
38#endif
39
43
44namespace net {
45namespace impl {
46namespace socket {
47
49 public:
50 virtual ~SocketServiceBase() = default;
51
53 int family, int sock_type, int protocol) const = 0;
54
57 socketpair(int family, int sock_type, int protocol) const = 0;
58
61
63 native_handle_type native_handle, unsigned long cmd,
64 void *data) const = 0;
65
68
70 native_handle_type native_handle, bool on) const = 0;
71
73 native_handle_type native_handle, int backlog) const = 0;
74
76 native_handle_type native_handle, int level, int optname,
77 const void *optval, socklen_t optlen) const = 0;
78
80 native_handle_type native_handle, int level, int optname, void *optval,
81 socklen_t *optlen) const = 0;
82
85 message_flags flags) const = 0;
86
89 message_flags flags) const = 0;
90
92 native_handle_type native_handle, const struct sockaddr *addr,
93 size_t addr_len) const = 0;
94
96 native_handle_type native_handle, const struct sockaddr *addr,
97 size_t addr_len) const = 0;
98
101 socklen_t *addr_len) const = 0;
102
103 // freebsd and linux have accept4()
104 // solaris and windows don't
107 socklen_t *addr_len, int flags = 0) const = 0;
108
111 size_t *addr_len) const = 0;
114 size_t *addr_len) const = 0;
115
116#ifdef __linux__
118 native_handle_type fd_out,
119 size_t len,
120 int flags) const = 0;
121#endif
122
124 native_handle_type fd_in, impl::file::file_handle_type fd_out, size_t len,
125 int flags) const = 0;
126
128 impl::file::file_handle_type fd_in, native_handle_type fd_out, size_t len,
129 int flags) const = 0;
130
132 wait_type wt) const = 0;
133
135 int how) const = 0;
136
137 virtual stdx::expected<
138 std::unique_ptr<struct addrinfo, void (*)(struct addrinfo *)>,
139 std::error_code>
140 getaddrinfo(const char *node, const char *service,
141 const addrinfo *hints) const = 0;
142};
143
144} // namespace socket
145} // namespace impl
146} // namespace net
147
148#endif
Definition: socket_service_base.h:48
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:944
static int flags[50]
Definition: hp_test1.cc:40
Definition: authentication.cc:36
int file_handle_type
Definition: file.h:53
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
std::error_code error_type
Definition: socket_constants.h:55
std::bitset< 31 > message_flags
Definition: socket_constants.h:64
int native_handle_type
Definition: socket_constants.h:51
Definition: buffer.h:45
native_handle_type native_handle()
Definition: process.h:56
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:2439
struct sockaddr sockaddr
Definition: sock_probe_win32.h:63