I have a TCP connection that works great as long as the other side works properly, but if the connection is cut for example because of a change of WiFi network on the other side the connection is stuck in half-open mode.
I regularly try to send data on this socket, so the connection loss should be detected immediately and give an exception in by select(), but when the connection is broken, lwIP is happy to keep send()ing data into the void until I get some random strange errors ( Connection already in progress (119) and No more processes (11)) instead of something like (Software caused connection abort (-1) or Connection reset by peer (104)).
I tried setsockopt()ing SO_SNDTIMEO, but I'm not sure this does anything. I saw there is some callback for timeouts, not sure if that's something to do with this, it seems to be part of the raw API.
Edit: On a related note, I have select() in one thread and send() in another thread. This has been working fine until I discovered the half-open problem, but now I read that lwIP send() and other functions are not thread safe? Do I need to handle my (asynchronous) send()s in my select() somwhow?
How to handle half-open TCP connection?
Re: How to handle half-open TCP connection?
I am new to the Esp32, so confirm what I say.
I saw a comment in the documentation that wifi and ble can interfere with each other of both are using the same cpu. The example I saw showed directing wifi to cpu0 and bluetooth to cpu1, or something like that.
Please take that as a hint since I am so green.
I saw a comment in the documentation that wifi and ble can interfere with each other of both are using the same cpu. The example I saw showed directing wifi to cpu0 and bluetooth to cpu1, or something like that.
Please take that as a hint since I am so green.
-
- Posts: 22
- Joined: Tue Oct 10, 2017 2:46 pm
Re: How to handle half-open TCP connection?
Not sure what you are trying to answer.
-
- Posts: 22
- Joined: Tue Oct 10, 2017 2:46 pm
Re: How to handle half-open TCP connection?
After reducing this option to 3 from the default 12 it actually times out and excepts the socket as it should:
Code: Select all
Maximum number of retransmissions of data segments (TCP_MAXRTX)
Who is online
Users browsing this forum: abbas1375, Bing [Bot] and 102 guests