Skip to content

Commit e99437c

Browse files
rtpmsysme-no-dev
andauthored
Add missing function getSocketOption (#7807)
* Update WiFiClient.h Added missing getSocketOption() with full access to level and option * Update WiFiClient.h * Handle timeout settings below 1 second Fix error with connect timeout settings below 1000ms. Add getsocketoptions function. * Add cast for setsockopt length --------- Co-authored-by: Me No Dev <[email protected]>
1 parent ac1c001 commit e99437c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

Diff for: libraries/WiFi/src/WiFiClient.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,16 @@ int WiFiClient::setSocketOption(int level, int option, const void* value, size_t
322322
return res;
323323
}
324324

325+
int WiFiClient::getSocketOption(int level, int option, const void* value, size_t size)
326+
{
327+
int res = getsockopt(fd(), level, option, (char *)value, (socklen_t*)&size);
328+
if(res < 0) {
329+
log_e("fail on fd %d, errno: %d, \"%s\"", fd(), errno, strerror(errno));
330+
}
331+
return res;
332+
}
333+
334+
325335
int WiFiClient::setTimeout(uint32_t seconds)
326336
{
327337
Client::setTimeout(seconds * 1000); // This should be here?

Diff for: libraries/WiFi/src/WiFiClient.h

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ class WiFiClient : public ESPLwIPClient
8888

8989
int setSocketOption(int option, char* value, size_t len);
9090
int setSocketOption(int level, int option, const void* value, size_t len);
91+
int getSocketOption(int level, int option, const void* value, size_t size);
9192
int setOption(int option, int *value);
9293
int getOption(int option, int *value);
9394
int setTimeout(uint32_t seconds);

0 commit comments

Comments
 (0)