MySQL  8.0.22
Source Code Documentation
net::impl::socket Namespace Reference

Classes

class  SocketService
 
class  SocketServiceBase
 

Typedefs

using native_handle_type = int
 
using error_type = std::error_code
 
using msghdr_base = ::msghdr
 
using iovec_base = ::iovec
 
using message_flags = std::bitset< 31 >
 

Enumerations

enum  wait_type { wait_type::wait_read = POLLIN, wait_type::wait_write = POLLOUT, wait_type::wait_error = POLLERR }
 

Functions

stdx::expected< native_handle_type, error_typesocket (int family, int sock_type, int protocol)
 
stdx::expected< void, std::error_code > close (native_handle_type native_handle)
 
stdx::expected< void, error_typeioctl (native_handle_type native_handle, unsigned long cmd, void *data)
 
stdx::expected< bool, error_typenative_non_blocking (native_handle_type native_handle)
 
stdx::expected< void, error_typenative_non_blocking (native_handle_type native_handle, bool on)
 
stdx::expected< void, error_typelisten (native_handle_type native_handle, int backlog)
 
stdx::expected< void, error_typesetsockopt (native_handle_type native_handle, int level, int optname, const void *optval, socklen_t optlen)
 
stdx::expected< void, error_typegetsockopt (native_handle_type native_handle, int level, int optname, void *optval, socklen_t *optlen)
 
stdx::expected< size_t, error_typerecv (native_handle_type native_handle, void *buf, size_t buf_len, message_flags flags)
 wrap recv() in a portable way. More...
 
stdx::expected< size_t, error_typeread (native_handle_type native_handle, void *data, size_t data_len)
 
stdx::expected< size_t, error_typerecvmsg (native_handle_type native_handle, msghdr_base &msg, message_flags flags)
 
stdx::expected< size_t, error_typesend (native_handle_type native_handle, const void *buf, size_t buf_len, message_flags flags)
 wrap send() in a portable way. More...
 
stdx::expected< size_t, error_typewrite (native_handle_type native_handle, const void *data, size_t data_len)
 
stdx::expected< size_t, error_typesendmsg (native_handle_type native_handle, msghdr_base &msg, message_flags flags)
 
stdx::expected< void, error_typebind (native_handle_type native_handle, const struct sockaddr *addr, size_t addr_len)
 wrap bind() in a portable way. More...
 
stdx::expected< void, error_typeconnect (native_handle_type native_handle, const struct sockaddr *addr, size_t addr_len)
 wrap connect() in a portable way. More...
 
stdx::expected< native_handle_type, error_typeaccept (native_handle_type native_handle, struct sockaddr *addr, socklen_t *addr_len)
 wrap accept() in a portable way. More...
 
stdx::expected< native_handle_type, error_typeaccept4 (native_handle_type native_handle, struct sockaddr *addr, socklen_t *addr_len, int flags=0)
 
stdx::expected< void, error_typegetsockname (native_handle_type native_handle, struct sockaddr *addr, size_t *addr_len)
 
stdx::expected< void, error_typegetpeername (native_handle_type native_handle, struct sockaddr *addr, size_t *addr_len)
 
stdx::expected< std::pair< native_handle_type, native_handle_type >, error_typesocketpair (int family, int sock_type, int protocol)
 socketpair(). More...
 
stdx::expected< size_t, error_typesplice_to_pipe (native_handle_type fd_in, impl::file::file_handle_type fd_out, size_t len, int flags)
 
stdx::expected< size_t, error_typesplice_from_pipe (impl::file::file_handle_type fd_in, native_handle_type fd_out, size_t len, int flags)
 
stdx::expected< void, error_typewait (native_handle_type fd, wait_type wt)
 
stdx::expected< void, error_typeshutdown (native_handle_type fd, int how)
 
stdx::expected< void, std::error_code > init ()
 Read the boundaries of the legacy dblwr buffer extents. More...
 
int last_error ()
 get last socket error. More...
 
std::error_code make_error_code (int errcode)
 make proper std::error_code for socket errno's More...
 
std::error_code last_error_code ()
 get last std::error_code for socket-errors. More...
 

Variables

constexpr const int kSocketError {-1}
 
constexpr const native_handle_type kInvalidSocket = -1
 
static constexpr message_flags message_peek = MSG_PEEK
 
static constexpr message_flags message_out_of_band = MSG_OOB
 
static constexpr message_flags message_do_not_route = MSG_DONTROUTE
 

Typedef Documentation

◆ error_type

using net::impl::socket::error_type = typedef std::error_code

◆ iovec_base

using net::impl::socket::iovec_base = typedef ::iovec

◆ message_flags

using net::impl::socket::message_flags = typedef std::bitset<31>

◆ msghdr_base

◆ native_handle_type

Enumeration Type Documentation

◆ wait_type

Enumerator
wait_read 
wait_write 
wait_error 

Function Documentation

◆ accept()

stdx::expected<native_handle_type, error_type> net::impl::socket::accept ( native_handle_type  native_handle,
struct sockaddr addr,
socklen_t *  addr_len 
)
inline

wrap accept() in a portable way.

◆ accept4()

stdx::expected<native_handle_type, error_type> net::impl::socket::accept4 ( native_handle_type  native_handle,
struct sockaddr addr,
socklen_t *  addr_len,
int  flags = 0 
)
inline

◆ bind()

stdx::expected<void, error_type> net::impl::socket::bind ( native_handle_type  native_handle,
const struct sockaddr addr,
size_t  addr_len 
)
inline

wrap bind() in a portable way.

◆ close()

stdx::expected<void, std::error_code> net::impl::socket::close ( native_handle_type  native_handle)
inline

◆ connect()

stdx::expected<void, error_type> net::impl::socket::connect ( native_handle_type  native_handle,
const struct sockaddr addr,
size_t  addr_len 
)
inline

wrap connect() in a portable way.

◆ getpeername()

stdx::expected<void, error_type> net::impl::socket::getpeername ( native_handle_type  native_handle,
struct sockaddr addr,
size_t *  addr_len 
)
inline

◆ getsockname()

stdx::expected<void, error_type> net::impl::socket::getsockname ( native_handle_type  native_handle,
struct sockaddr addr,
size_t *  addr_len 
)
inline

◆ getsockopt()

stdx::expected<void, error_type> net::impl::socket::getsockopt ( native_handle_type  native_handle,
int  level,
int  optname,
void *  optval,
socklen_t *  optlen 
)
inline

◆ init()

stdx::expected<void, std::error_code> net::impl::socket::init ( )
inlinenoexcept

Read the boundaries of the legacy dblwr buffer extents.

Returns
DB_SUCCESS or error code.

◆ ioctl()

stdx::expected<void, error_type> net::impl::socket::ioctl ( native_handle_type  native_handle,
unsigned long  cmd,
void *  data 
)
inline

◆ last_error()

int net::impl::socket::last_error ( )
inline

get last socket error.

◆ last_error_code()

std::error_code net::impl::socket::last_error_code ( )
inline

get last std::error_code for socket-errors.

◆ listen()

stdx::expected<void, error_type> net::impl::socket::listen ( native_handle_type  native_handle,
int  backlog 
)
inline

◆ make_error_code()

std::error_code net::impl::socket::make_error_code ( int  errcode)
inline

make proper std::error_code for socket errno's

On windows, WSAGetLastError() returns a code from the system-category On POSIX systems, errno returns a code from the generic-category

◆ native_non_blocking() [1/2]

stdx::expected<bool, error_type> net::impl::socket::native_non_blocking ( native_handle_type  native_handle)
inline

◆ native_non_blocking() [2/2]

stdx::expected<void, error_type> net::impl::socket::native_non_blocking ( native_handle_type  native_handle,
bool  on 
)
inline

◆ read()

stdx::expected<size_t, error_type> net::impl::socket::read ( native_handle_type  native_handle,
void *  data,
size_t  data_len 
)
inline

◆ recv()

stdx::expected<size_t, error_type> net::impl::socket::recv ( native_handle_type  native_handle,
void *  buf,
size_t  buf_len,
message_flags  flags 
)
inline

wrap recv() in a portable way.

Parameters
native_handlesocket handle
bufpointer to a mutable buffer of size 'buf_len'
buf_lensize of 'buf'
flagsmessage flags
Returns
bytes transferred on success, std::error_code otherwise

◆ recvmsg()

stdx::expected<size_t, error_type> net::impl::socket::recvmsg ( native_handle_type  native_handle,
msghdr_base msg,
message_flags  flags 
)
inline

◆ send()

stdx::expected<size_t, error_type> net::impl::socket::send ( native_handle_type  native_handle,
const void *  buf,
size_t  buf_len,
message_flags  flags 
)
inline

wrap send() in a portable way.

Parameters
native_handlesocket handle
bufpointer to a const buffer of size 'buf_len'
buf_lensize of 'buf'
flagsmessage flags
Returns
bytes transferred on success, std::error_code otherwise

◆ sendmsg()

stdx::expected<size_t, error_type> net::impl::socket::sendmsg ( native_handle_type  native_handle,
msghdr_base msg,
message_flags  flags 
)
inline

◆ setsockopt()

stdx::expected<void, error_type> net::impl::socket::setsockopt ( native_handle_type  native_handle,
int  level,
int  optname,
const void *  optval,
socklen_t  optlen 
)
inline

◆ shutdown()

stdx::expected<void, error_type> net::impl::socket::shutdown ( native_handle_type  fd,
int  how 
)
inline

◆ socket()

stdx::expected<native_handle_type, error_type> net::impl::socket::socket ( int  family,
int  sock_type,
int  protocol 
)
inline

◆ socketpair()

stdx::expected<std::pair<native_handle_type, native_handle_type>, error_type> net::impl::socket::socketpair ( int  family,
int  sock_type,
int  protocol 
)
inline

socketpair().

  • wraps socketpair() on POSIX
  • emualated on windows via a AF_INET + SOCK_STREAM socket on localhost on a system assigned port.

◆ splice_from_pipe()

stdx::expected<size_t, error_type> net::impl::socket::splice_from_pipe ( impl::file::file_handle_type  fd_in,
native_handle_type  fd_out,
size_t  len,
int  flags 
)
inline

◆ splice_to_pipe()

stdx::expected<size_t, error_type> net::impl::socket::splice_to_pipe ( native_handle_type  fd_in,
impl::file::file_handle_type  fd_out,
size_t  len,
int  flags 
)
inline

◆ wait()

stdx::expected<void, error_type> net::impl::socket::wait ( native_handle_type  fd,
wait_type  wt 
)
inline

◆ write()

stdx::expected<size_t, error_type> net::impl::socket::write ( native_handle_type  native_handle,
const void *  data,
size_t  data_len 
)
inline

Variable Documentation

◆ kInvalidSocket

constexpr const native_handle_type net::impl::socket::kInvalidSocket = -1

◆ kSocketError

constexpr const int net::impl::socket::kSocketError {-1}

◆ message_do_not_route

constexpr message_flags net::impl::socket::message_do_not_route = MSG_DONTROUTE
static

◆ message_out_of_band

constexpr message_flags net::impl::socket::message_out_of_band = MSG_OOB
static

◆ message_peek

constexpr message_flags net::impl::socket::message_peek = MSG_PEEK
static