4#ifdef USE_SOCKET_IMPL_LWIP_TCP
37 bool ready()
const {
return false; }
88 static void s_recv_fn(
void *arg,
struct udp_pcb *pcb,
struct pbuf *p,
const ip_addr_t *addr, u16_t port);
UDP socket with receive support for LWIP raw API.
static constexpr uint8_t UDP_RX_MASK
LWIPRawUDPImpl(sa_family_t family, struct udp_pcb *pcb)
Caller (the factory) must hold the lwip lock; registers the recv callback.
ssize_t recvfrom(void *buf, size_t len, struct sockaddr *src_addr, socklen_t *addrlen)
Read the next queued packet and return the source address.
int close()
Close the socket, flushing any queued rx packets first.
ssize_t read(void *buf, size_t len)
Read the next queued packet, discarding source address info.
bool ready() const
Returns true if there are packets available to read.
void recv_fn_(struct pbuf *p, const ip_addr_t *addr, u16_t port)
static void s_recv_fn(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
static constexpr uint8_t UDP_RX_QUEUE_SIZE
Ring buffer for received UDP packets.
std::array< UDPRxPacket, UDP_RX_QUEUE_SIZE > rx_queue_
uint16_t get_rx_dropped() const
Number of packets dropped because the rx queue was full (saturating).
Send-only UDP socket implementation for LWIP raw API.
LWIPRawUDPSendImpl(sa_family_t family, struct udp_pcb *pcb)
The pcb is allocated by the factory (like the TCP impl); never null here.
int getsockopt(int level, int optname, void *optval, socklen_t *optlen)
LWIPRawUDPSendImpl & operator=(const LWIPRawUDPSendImpl &)=delete
int setblocking(bool blocking)
LWIPRawUDPSendImpl(const LWIPRawUDPSendImpl &)=delete
int bind(const struct sockaddr *name, socklen_t addrlen)
int setsockopt(int level, int optname, const void *optval, socklen_t optlen)
int ip2sockaddr_(const ip_addr_t *ip, uint16_t port, struct sockaddr *name, socklen_t *addrlen)
Convert lwip ip_addr_t and port to sockaddr.
int close_internal_locked_()
Shared close logic — removes the udp pcb. Caller must hold LWIP_LOCK.
ssize_t sendto(const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen)
Send a UDP packet to the specified destination.