I'm not a big expert in lwIP, but I think the code is correct, since I spent time debugging it on ESP32 and it works very well there. If one code for transmitting data over TCP over WiFi works on ESP32 and does not work on ESP32-S2, I tend to think that the problem is still in ESP32-S2 or in the implementation of lwIP in ESP-IDF 4.2 for ESP32-S2. I would like to find an answer to this question, and find a solution to the problem : data transfer over TCP to one server via several sockets.
esp32-s2 for multisocket transfer - ESP32 Forum