LWIP reopen close TCP port ( urgent)

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

LWIP reopen close TCP port ( urgent)

Postby snahmad75 » Fri Jan 25, 2019 2:04 pm

Hi,

I have program. which open TCP port for example 60001 for listening.
then TCP client connect.then I close socket. reopen same TCP port. It fails to open TCP listen socket "failed to open listener" because there is one or more tcp client is connected.

If donot have any client connected or client close connection before TCP server close socket. It works.

open different port also works.

Every I open same port. I get different socket handle.

I am using mongoose Networking library. It is working on Windows Platform.

To close by calling mg_mgr_free and do mg_mgr_init again then mg_bind failed which open tcp port.
I also keep list of mongoose client connections. I do closeSocket for each connected as well before and after mg_mgr_free .

Kindly help. If I restart my firmware then it works as well.

My guess is either mongoose is not closing socket properly. or something wrong with LWIP config.

My LWIP config.

#
# LWIP
#
CONFIG_L2_TO_L3_COPY=
CONFIG_LWIP_IRAM_OPTIMIZATION=
CONFIG_LWIP_MAX_SOCKETS=10
CONFIG_USE_ONLY_LWIP_SELECT=
CONFIG_LWIP_SO_REUSE=y
CONFIG_LWIP_SO_REUSE_RXTOALL=y
CONFIG_LWIP_SO_RCVBUF=y
CONFIG_LWIP_DHCP_MAX_NTP_SERVERS=1
CONFIG_LWIP_IP_FRAG=y
CONFIG_LWIP_IP_REASSEMBLY=
CONFIG_LWIP_STATS=y
CONFIG_LWIP_ETHARP_TRUST_IP_MAC=y
CONFIG_ESP_GRATUITOUS_ARP=
CONFIG_TCPIP_RECVMBOX_SIZE=32
CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y
CONFIG_LWIP_DHCP_RESTORE_LAST_IP=


#
# TCP
#
CONFIG_LWIP_MAX_ACTIVE_TCP=6
CONFIG_LWIP_MAX_LISTENING_TCP=5
CONFIG_TCP_MAXRTX=12
CONFIG_TCP_SYNMAXRTX=6
CONFIG_TCP_MSS=1436
CONFIG_TCP_MSL=60000
CONFIG_TCP_SND_BUF_DEFAULT=5744
CONFIG_TCP_WND_DEFAULT=5744
CONFIG_TCP_RECVMBOX_SIZE=6
CONFIG_TCP_QUEUE_OOSEQ=y
CONFIG_ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES=y
CONFIG_TCP_OVERSIZE_MSS=y
CONFIG_TCP_OVERSIZE_QUARTER_MSS=
CONFIG_TCP_OVERSIZE_DISABLE=


# ICMP
#
CONFIG_LWIP_MULTICAST_PING=
CONFIG_LWIP_BROADCAST_PING=

#
# LWIP RAW API
#
CONFIG_LWIP_MAX_RAW_PCBS=16


# TCP/IP Adapter
#
CONFIG_IP_LOST_TIMER_INTERVAL=10
CONFIG_TCPIP_LWIP=y


Thanks,
Naeem

Who is online

Users browsing this forum: Gaston1980 and 168 guests