@@ -1310,7 +1310,11 @@ void CConnman::CreateNodeFromAcceptedSocket(std::unique_ptr<Sock>&& sock,
1310
1310
1311
1311
// According to the internet TCP_NODELAY is not carried into accepted sockets
1312
1312
// on all platforms. Set it again here just to be sure.
1313
- SetSocketNoDelay (sock->Get ());
1313
+ const int on{1 };
1314
+ if (sock->SetSockOpt (IPPROTO_TCP, TCP_NODELAY, &on, sizeof (on)) == SOCKET_ERROR) {
1315
+ LogPrint (BCLog::NET, " connection from %s: unable to set TCP_NODELAY, continuing anyway\n " ,
1316
+ addr.ToString ());
1317
+ }
1314
1318
1315
1319
// Don't accept connections from banned peers.
1316
1320
bool banned = m_banman && m_banman->IsBanned (addr);
@@ -3219,17 +3223,26 @@ bool CConnman::BindListenPort(const CService& addrBind, bilingual_str& strError,
3219
3223
3220
3224
// Allow binding if the port is still in TIME_WAIT state after
3221
3225
// the program was closed and restarted.
3222
- setsockopt (sock->Get (), SOL_SOCKET, SO_REUSEADDR, (sockopt_arg_type)&nOne, sizeof (int ));
3226
+ if (sock->SetSockOpt (SOL_SOCKET, SO_REUSEADDR, (sockopt_arg_type)&nOne, sizeof (int )) == SOCKET_ERROR) {
3227
+ strError = strprintf (Untranslated (" Error setting SO_REUSEADDR on socket: %s, continuing anyway" ), NetworkErrorString (WSAGetLastError ()));
3228
+ LogPrintf (" %s\n " , strError.original );
3229
+ }
3223
3230
3224
3231
// some systems don't have IPV6_V6ONLY but are always v6only; others do have the option
3225
3232
// and enable it by default or not. Try to enable it, if possible.
3226
3233
if (addrBind.IsIPv6 ()) {
3227
3234
#ifdef IPV6_V6ONLY
3228
- setsockopt (sock->Get (), IPPROTO_IPV6, IPV6_V6ONLY, (sockopt_arg_type)&nOne, sizeof (int ));
3235
+ if (sock->SetSockOpt (IPPROTO_IPV6, IPV6_V6ONLY, (sockopt_arg_type)&nOne, sizeof (int )) == SOCKET_ERROR) {
3236
+ strError = strprintf (Untranslated (" Error setting IPV6_V6ONLY on socket: %s, continuing anyway" ), NetworkErrorString (WSAGetLastError ()));
3237
+ LogPrintf (" %s\n " , strError.original );
3238
+ }
3229
3239
#endif
3230
3240
#ifdef WIN32
3231
3241
int nProtLevel = PROTECTION_LEVEL_UNRESTRICTED;
3232
- setsockopt (sock->Get (), IPPROTO_IPV6, IPV6_PROTECTION_LEVEL, (const char *)&nProtLevel, sizeof (int ));
3242
+ if (sock->SetSockOpt (IPPROTO_IPV6, IPV6_PROTECTION_LEVEL, (const char *)&nProtLevel, sizeof (int )) == SOCKET_ERROR) {
3243
+ strError = strprintf (Untranslated (" Error setting IPV6_PROTECTION_LEVEL on socket: %s, continuing anyway" ), NetworkErrorString (WSAGetLastError ()));
3244
+ LogPrintf (" %s\n " , strError.original );
3245
+ }
3233
3246
#endif
3234
3247
}
3235
3248
0 commit comments