5#ifdef USE_SOCKET_IMPL_BSD_SOCKETS
15 if (monitor_loop && this->
fd_ >= 0) {
41 int fl = ::fcntl(this->
fd_, F_GETFL, 0);
47 ::fcntl(this->
fd_, F_SETFL, fl);
74static std::unique_ptr<BSDSocketImpl> create_socket(
int domain,
int type,
int protocol,
bool loop_monitored =
false) {
75 int ret = ::socket(domain,
type, protocol);
78 return make_unique<BSDSocketImpl>(ret, loop_monitored);
81std::unique_ptr<Socket>
socket(
int domain,
int type,
int protocol) {
82 return create_socket(domain,
type, protocol,
false);
86 return create_socket(domain,
type, protocol,
true);
90 return create_socket(domain,
type, protocol,
false);
94 return create_socket(domain,
type, protocol,
true);
void unregister_socket_fd(int fd)
bool register_socket_fd(int fd)
Register/unregister a socket file descriptor to be monitored for read events.
int setblocking(bool blocking)
int getpeername(struct sockaddr *addr, socklen_t *addrlen)
size_t getpeername_to(std::span< char, SOCKADDR_STR_LEN > buf)
Format peer address into a fixed-size buffer (no heap allocation)
size_t getsockname_to(std::span< char, SOCKADDR_STR_LEN > buf)
Format local address into a fixed-size buffer (no heap allocation)
int getsockname(struct sockaddr *addr, socklen_t *addrlen)
BSDSocketImpl(int fd, bool monitor_loop=false)
size_t format_sockaddr_to(const struct sockaddr *addr_ptr, socklen_t len, std::span< char, SOCKADDR_STR_LEN > buf)
Format sockaddr into caller-provided buffer, returns length written (excluding null)
std::unique_ptr< ListenSocket > socket_listen(int domain, int type, int protocol)
Create a listening socket of the given domain, type and protocol.
std::unique_ptr< ListenSocket > socket_listen_loop_monitored(int domain, int type, int protocol)
Create a listening socket and monitor it for data in the main loop.
std::unique_ptr< Socket > socket(int domain, int type, int protocol)
Create a socket of the given domain, type and protocol.
bool socket_ready_fd(int fd, bool loop_monitored)
Shared ready() helper for fd-based socket implementations.
std::unique_ptr< Socket > socket_loop_monitored(int domain, int type, int protocol)
Create a socket and monitor it for data in the main loop.
Application App
Global storage of Application pointer - only one Application can exist.