Skip to content

Commit 5b1a869

Browse files
authored
Update WiFiClient.cpp
This change will allow specifying connect timeouts below 1 second. Without this change, if connect timeouts under 1 second are given, the connect defaults to 0ms and fails. This will also allow timeouts in fractions of seconds, e.g. 1500ms. Without this change, connect timeouts are truncated to full second increments.
1 parent 778674b commit 5b1a869

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libraries/WiFi/src/WiFiClient.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ int WiFiClient::connect(IPAddress ip, uint16_t port, int32_t timeout)
231231
FD_ZERO(&fdset);
232232
FD_SET(sockfd, &fdset);
233233
tv.tv_sec = _timeout / 1000;
234-
tv.tv_usec = 0;
234+
tv.tv_usec = (_timeout % 1000) * 1000;
235235

236236
#ifdef ESP_IDF_VERSION_MAJOR
237237
int res = lwip_connect(sockfd, (struct sockaddr*)&serveraddr, sizeof(serveraddr));

0 commit comments

Comments
 (0)