Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix set/getSocketOption inheritance #7480

Merged
merged 2 commits into from Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/WiFi/src/WiFiClient.h
Expand Up @@ -84,7 +84,7 @@ class WiFiClient : public ESPLwIPClient
return !this->operator==(rhs);
};

int fd() const;
virtual int fd() const;

int setSocketOption(int option, char* value, size_t len);
int setSocketOption(int level, int option, const void* value, size_t len);
Expand Down
13 changes: 3 additions & 10 deletions libraries/WiFiClientSecure/src/WiFiClientSecure.cpp
Expand Up @@ -376,16 +376,9 @@ int WiFiClientSecure::setTimeout(uint32_t seconds)
return 0;
}
}
int WiFiClientSecure::setSocketOption(int option, char* value, size_t len)
{
return setSocketOption(SOL_SOCKET, option, (const void*)value, len);
}

int WiFiClientSecure::setSocketOption(int level, int option, const void* value, size_t len)
int WiFiClientSecure::fd() const
{
int res = setsockopt(sslclient->socket, level, option, value, len);
if(res < 0) {
log_e("fail on %d, errno: %d, \"%s\"", sslclient->socket, errno, strerror(errno));
}
return res;
return sslclient->socket;
}

3 changes: 1 addition & 2 deletions libraries/WiFiClientSecure/src/WiFiClientSecure.h
Expand Up @@ -80,8 +80,7 @@ class WiFiClientSecure : public WiFiClient
const mbedtls_x509_crt* getPeerCertificate() { return mbedtls_ssl_get_peer_cert(&sslclient->ssl_ctx); };
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);
int fd() const;

operator bool()
{
Expand Down