5#ifdef USE_SOCKET_IMPL_BSD_SOCKETS
21 int flags = ::fcntl(this->
fd_, F_GETFD, 0);
23 ::fcntl(this->
fd_, F_SETFD,
flags | FD_CLOEXEC);
29#ifdef USE_LWIP_FAST_SELECT
31#elif defined(USE_HOST)
43#ifdef USE_LWIP_FAST_SELECT
50#elif defined(USE_HOST)
61 int fl = ::fcntl(this->
fd_, F_GETFL, 0);
67 ::fcntl(this->
fd_, F_SETFL, fl);
92static std::unique_ptr<BSDSocketImpl> create_socket(
int domain,
int type,
int protocol,
bool loop_monitored =
false) {
93 int ret = ::socket(domain,
type, protocol);
96 return make_unique<BSDSocketImpl>(ret, loop_monitored);
99std::unique_ptr<Socket>
socket(
int domain,
int type,
int protocol) {
100 return create_socket(domain,
type, protocol,
false);
104 return create_socket(domain,
type, protocol,
true);
int setblocking(bool blocking)
int getpeername(struct sockaddr *addr, socklen_t *addrlen)
struct lwip_sock * cached_sock_
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< Socket > socket(int domain, int type, int protocol)
Create a socket of the given domain, type and protocol.
struct lwip_sock * hook_fd_for_fast_select(int fd)
Resolve an fd to its lwip_sock and install the netconn event-callback hook so the main loop is woken ...
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.
bool wake_register_fd(int fd)
Register a socket file descriptor with the host select() loop.
void wake_unregister_fd(int fd)
Unregister a socket file descriptor. Not thread-safe — main loop only.
Platform-specific main loop wake primitives.