MySQL 8.0.40
Source Code Documentation
socket_service.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_H_
27#define MYSQL_HARNESS_NET_TS_IMPL_SOCKET_SERVICE_H_
28
33
34namespace net {
35namespace impl {
36namespace socket {
37
39 public:
41 int family, int sock_type, int protocol) const override {
42 return socket::socket(family, sock_type, protocol);
43 }
44
46 socketpair(int family, int sock_type, int protocol) const override {
47 return socket::socketpair(family, sock_type, protocol);
48 }
49
51 native_handle_type native_handle) const override {
53 }
54
56 unsigned long cmd,
57 void *data) const override {
58 return socket::ioctl(native_handle, cmd, data);
59 }
60
62 native_handle_type native_handle) const override {
64 }
65
67 native_handle_type native_handle, bool on) const override {
69 }
70
72 int backlog) const override {
73 return socket::listen(native_handle, backlog);
74 }
75
77 int level, int optname,
78 const void *optval,
79 socklen_t optlen) const override {
80 return socket::setsockopt(native_handle, level, optname, optval, optlen);
81 }
82
84 native_handle_type native_handle, int level, int optname, void *optval,
85 socklen_t *optlen) const override {
86 return socket::getsockopt(native_handle, level, optname, optval, optlen);
87 }
88
91 message_flags flags) const override {
93 }
94
97 message_flags flags) const override {
99 }
100
102 const struct sockaddr *addr,
103 size_t addr_len) const override {
104 return socket::bind(native_handle, addr, addr_len);
105 }
106
108 const struct sockaddr *addr,
109 size_t addr_len) const override {
110 return socket::connect(native_handle, addr, addr_len);
111 }
112
115 socklen_t *addr_len) const override {
116 return socket::accept(native_handle, addr, addr_len);
117 }
118
119 // freebsd and linux have accept4()
120 // solaris and windows don't
123 socklen_t *addr_len, int flags = 0) const override {
124 return socket::accept4(native_handle, addr, addr_len, flags);
125 }
126
129 size_t *addr_len) const override {
130 return socket::getsockname(native_handle, addr, addr_len);
131 }
132
135 size_t *addr_len) const override {
136 return socket::getpeername(native_handle, addr, addr_len);
137 }
138
139#ifdef __linux__
141 native_handle_type fd_out,
142 size_t len,
143 int flags) const override {
144 return socket::splice(fd_in, fd_out, len, flags);
145 }
146#endif
147
149 native_handle_type fd_in, impl::file::file_handle_type fd_out, size_t len,
150 int flags) const override {
151 return socket::splice_to_pipe(fd_in, fd_out, len, flags);
152 }
153
155 impl::file::file_handle_type fd_in, native_handle_type fd_out, size_t len,
156 int flags) const override {
157 return socket::splice_from_pipe(fd_in, fd_out, len, flags);
158 }
159
161 wait_type wt) const override {
162 return socket::wait(fd, wt);
163 }
164
166 int how) const override {
167 return socket::shutdown(fd, how);
168 }
169
170 stdx::expected<std::unique_ptr<struct addrinfo, void (*)(struct addrinfo *)>,
171 std::error_code>
172 getaddrinfo(const char *node, const char *service,
173 const addrinfo *hints) const override {
174 return resolver::getaddrinfo(node, service, hints);
175 }
176};
177
178} // namespace socket
179} // namespace impl
180} // namespace net
181
182#endif
Definition: socket_service_base.h:48
Definition: socket_service.h:38
stdx::expected< void, error_type > getsockopt(native_handle_type native_handle, int level, int optname, void *optval, socklen_t *optlen) const override
Definition: socket_service.h:83
stdx::expected< void, error_type > connect(native_handle_type native_handle, const struct sockaddr *addr, size_t addr_len) const override
Definition: socket_service.h:107
stdx::expected< native_handle_type, error_type > socket(int family, int sock_type, int protocol) const override
Definition: socket_service.h:40
stdx::expected< void, error_type > listen(native_handle_type native_handle, int backlog) const override
Definition: socket_service.h:71
stdx::expected< void, error_type > wait(native_handle_type fd, wait_type wt) const override
Definition: socket_service.h:160
stdx::expected< void, error_type > bind(native_handle_type native_handle, const struct sockaddr *addr, size_t addr_len) const override
Definition: socket_service.h:101
stdx::expected< void, error_type > shutdown(native_handle_type fd, int how) const override
Definition: socket_service.h:165
stdx::expected< void, error_type > setsockopt(native_handle_type native_handle, int level, int optname, const void *optval, socklen_t optlen) const override
Definition: socket_service.h:76
stdx::expected< size_t, error_type > sendmsg(native_handle_type native_handle, msghdr_base &msg, message_flags flags) const override
Definition: socket_service.h:95
stdx::expected< size_t, error_type > recvmsg(native_handle_type native_handle, msghdr_base &msg, message_flags flags) const override
Definition: socket_service.h:89
stdx::expected< void, std::error_code > close(native_handle_type native_handle) const override
Definition: socket_service.h:50
stdx::expected< void, error_type > getpeername(native_handle_type native_handle, struct sockaddr *addr, size_t *addr_len) const override
Definition: socket_service.h:133
stdx::expected< native_handle_type, error_type > accept(native_handle_type native_handle, struct sockaddr *addr, socklen_t *addr_len) const override
Definition: socket_service.h:113
stdx::expected< void, error_type > getsockname(native_handle_type native_handle, struct sockaddr *addr, size_t *addr_len) const override
Definition: socket_service.h:127
stdx::expected< std::unique_ptr< struct addrinfo, void(*)(struct addrinfo *)>, std::error_code > getaddrinfo(const char *node, const char *service, const addrinfo *hints) const override
Definition: socket_service.h:172
stdx::expected< bool, error_type > native_non_blocking(native_handle_type native_handle) const override
Definition: socket_service.h:61
stdx::expected< native_handle_type, error_type > accept4(native_handle_type native_handle, struct sockaddr *addr, socklen_t *addr_len, int flags=0) const override
Definition: socket_service.h:121
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 override
Definition: socket_service.h:154
stdx::expected< void, error_type > native_non_blocking(native_handle_type native_handle, bool on) const override
Definition: socket_service.h:66
stdx::expected< void, error_type > ioctl(native_handle_type native_handle, unsigned long cmd, void *data) const override
Definition: socket_service.h:55
stdx::expected< std::pair< native_handle_type, native_handle_type >, error_type > socketpair(int family, int sock_type, int protocol) const override
Definition: socket_service.h:46
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 override
Definition: socket_service.h:148
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< std::unique_ptr< struct addrinfo, void(*)(struct addrinfo *)>, std::error_code > getaddrinfo(const char *node, const char *service, const struct addrinfo *hints)
Definition: resolver.h:229
stdx::expected< size_t, error_type > sendmsg(native_handle_type native_handle, msghdr_base &msg, message_flags flags)
Definition: socket.h:310
stdx::expected< void, error_type > listen(native_handle_type native_handle, int backlog)
Definition: socket.h:149
stdx::expected< void, error_type > getsockname(native_handle_type native_handle, struct sockaddr *addr, size_t *addr_len)
Definition: socket.h:403
stdx::expected< native_handle_type, error_type > socket(int family, int sock_type, int protocol)
Definition: socket.h:63
stdx::expected< std::pair< native_handle_type, native_handle_type >, error_type > socketpair(int family, int sock_type, int protocol)
socketpair().
Definition: socket.h:453
stdx::expected< void, error_type > bind(native_handle_type native_handle, const struct sockaddr *addr, size_t addr_len)
wrap bind() in a portable way.
Definition: socket.h:339
stdx::expected< void, error_type > ioctl(native_handle_type native_handle, unsigned long cmd, void *data)
Definition: socket.h:89
stdx::expected< size_t, error_type > recvmsg(native_handle_type native_handle, msghdr_base &msg, message_flags flags)
Definition: socket.h:235
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)
Definition: socket.h:604
stdx::expected< void, error_type > getpeername(native_handle_type native_handle, struct sockaddr *addr, size_t *addr_len)
Definition: socket.h:424
stdx::expected< native_handle_type, error_type > accept(native_handle_type native_handle, struct sockaddr *addr, socklen_t *addr_len)
wrap accept() in a portable way.
Definition: socket.h:367
stdx::expected< void, std::error_code > close(native_handle_type native_handle)
Definition: socket.h:75
stdx::expected< native_handle_type, error_type > accept4(native_handle_type native_handle, struct sockaddr *addr, socklen_t *addr_len, int flags=0)
Definition: socket.h:380
wait_type
Definition: socket_constants.h:86
stdx::expected< void, error_type > setsockopt(native_handle_type native_handle, int level, int optname, const void *optval, socklen_t optlen)
Definition: socket.h:158
stdx::expected< bool, error_type > native_non_blocking(native_handle_type native_handle)
Definition: socket.h:106
::msghdr msghdr_base
Definition: socket_constants.h:60
stdx::expected< void, error_type > connect(native_handle_type native_handle, const struct sockaddr *addr, size_t addr_len)
wrap connect() in a portable way.
Definition: socket.h:353
std::error_code error_type
Definition: socket_constants.h:55
std::bitset< 31 > message_flags
Definition: socket_constants.h:64
stdx::expected< void, error_type > shutdown(native_handle_type fd, int how)
Definition: socket.h:663
int native_handle_type
Definition: socket_constants.h:51
stdx::expected< void, error_type > wait(native_handle_type fd, wait_type wt)
Definition: socket.h:636
stdx::expected< void, error_type > getsockopt(native_handle_type native_handle, int level, int optname, void *optval, socklen_t *optlen)
Definition: socket.h:174
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)
Definition: socket.h:620
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