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