Enable, use SOF_REUSEADDR

This is the lwip no-os version of SO_REUSEADDR, which is set on all
listening sockets in the espressif port; do so here as well,
it makes running servers easier. The "address in use" error does
not occur.
This commit is contained in:
Jeff Epler 2022-10-25 10:09:16 -05:00
parent edce717cfc
commit f997d0053d
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE
3 changed files with 4 additions and 0 deletions

View File

@ -852,6 +852,8 @@ bool common_hal_socketpool_socket_bind(socketpool_socket_obj_t *socket,
mp_raise_OSError(EHOSTUNREACH);
}
ip_set_option(socket->pcb.ip, SOF_REUSEADDR);
err_t err = ERR_ARG;
switch (socket->type) {
case MOD_NETWORK_SOCK_STREAM: {

View File

@ -37,6 +37,7 @@ typedef struct _lwip_socket_obj_t {
mp_obj_base_t base;
volatile union {
struct tcp_pcb *ip;
struct tcp_pcb *tcp;
struct udp_pcb *udp;
struct raw_pcb *raw;

View File

@ -52,6 +52,7 @@
#define LWIP_NETIF_TX_SINGLE_PBUF 1
#define DHCP_DOES_ARP_CHECK 0
#define LWIP_DHCP_DOES_ACD_CHECK 0
#define SO_REUSE 1
#ifndef NDEBUG
#define LWIP_DEBUG 1