Reputation: 11
When i try to send message to server using TCP socket on esp 32 and when the host is unreachable program trying to connect to server for about 15 seconds when it tries to send message. I need to set that timeout from 15 second to 2-3 secs like in C#:
TcpClient client.ReceiveTimeout = 2000;
.
Is there anyway to do that on ESP32?
P.S IT SHOULD BE LIKE THIS, server might be unreachable and i have to handle this event
Upvotes: 1
Views: 1327
Reputation: 1
I tried it with success in my sketch on board "Heltec WiFi LoRa 32 (v2)"
WiFiClient client_A;
client_A.connect(serverIP, portNumber, 2000);
Upvotes: 0
Reputation: 3736
You can specify the connect timeout as parameter of connect
int connect(IPAddress ip, uint16_t port, int32_t timeout);
int connect(const char *host, uint16_t port, int32_t timeout);
the timeout is in milliseconds
Upvotes: 1