Add full setsocketoption to WifiClient and WifiClientSecure (#7030)
This commit is contained in:
parent
12169d8586
commit
cb3ffd0b44
4 changed files with 17 additions and 9 deletions
|
|
@ -303,9 +303,14 @@ int WiFiClient::connect(const char *host, uint16_t port, int32_t timeout)
|
|||
|
||||
int WiFiClient::setSocketOption(int option, char* value, size_t len)
|
||||
{
|
||||
int res = setsockopt(fd(), SOL_SOCKET, option, value, len);
|
||||
return setSocketOption(SOL_SOCKET, option, (const void*)value, len);
|
||||
}
|
||||
|
||||
int WiFiClient::setSocketOption(int level, int option, const void* value, size_t len)
|
||||
{
|
||||
int res = setsockopt(fd(), level, option, value, len);
|
||||
if(res < 0) {
|
||||
log_e("%X : %d", option, errno);
|
||||
log_e("fail on %d, errno: %d, \"%s\"", fd(), errno, strerror(errno));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
@ -330,11 +335,7 @@ int WiFiClient::setTimeout(uint32_t seconds)
|
|||
|
||||
int WiFiClient::setOption(int option, int *value)
|
||||
{
|
||||
int res = setsockopt(fd(), IPPROTO_TCP, option, (char *) value, sizeof(int));
|
||||
if(res < 0) {
|
||||
log_e("fail on fd %d, errno: %d, \"%s\"", fd(), errno, strerror(errno));
|
||||
}
|
||||
return res;
|
||||
return setSocketOption(IPPROTO_TCP, option, (const void*)value, sizeof(int));
|
||||
}
|
||||
|
||||
int WiFiClient::getOption(int option, int *value)
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ public:
|
|||
int fd() const;
|
||||
|
||||
int setSocketOption(int option, char* value, size_t len);
|
||||
int setSocketOption(int level, int option, const void* value, size_t len);
|
||||
int setOption(int option, int *value);
|
||||
int getOption(int option, int *value);
|
||||
int setTimeout(uint32_t seconds);
|
||||
|
|
|
|||
|
|
@ -378,9 +378,14 @@ int WiFiClientSecure::setTimeout(uint32_t seconds)
|
|||
}
|
||||
int WiFiClientSecure::setSocketOption(int option, char* value, size_t len)
|
||||
{
|
||||
int res = setsockopt(sslclient->socket, SOL_SOCKET, option, value, len);
|
||||
return setSocketOption(SOL_SOCKET, option, (const void*)value, len);
|
||||
}
|
||||
|
||||
int WiFiClientSecure::setSocketOption(int level, int option, const void* value, size_t len)
|
||||
{
|
||||
int res = setsockopt(sslclient->socket, level, option, value, len);
|
||||
if(res < 0) {
|
||||
log_e("%X : %d", option, errno);
|
||||
log_e("fail on %d, errno: %d, \"%s\"", sslclient->socket, errno, strerror(errno));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ public:
|
|||
bool getFingerprintSHA256(uint8_t sha256_result[32]) { return get_peer_fingerprint(sslclient, sha256_result); };
|
||||
int setTimeout(uint32_t seconds);
|
||||
int setSocketOption(int option, char* value, size_t len);
|
||||
int setSocketOption(int level, int option, const void* value, size_t len);
|
||||
|
||||
operator bool()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue