@@ -2395,17 +2395,26 @@ bool CConnman::BindListenPort(const CService& addrBind, bilingual_str& strError,
2395
2395
2396
2396
// Allow binding if the port is still in TIME_WAIT state after
2397
2397
// the program was closed and restarted.
2398
- setsockopt (sock->Get (), SOL_SOCKET, SO_REUSEADDR, (sockopt_arg_type)&nOne, sizeof (int ));
2398
+ if (sock->SetSockOpt (SOL_SOCKET, SO_REUSEADDR, (sockopt_arg_type)&nOne, sizeof (int )) == SOCKET_ERROR) {
2399
+ strError = strprintf (Untranslated (" Error setting SO_REUSEADDR on socket: %s, continuing anyway" ), NetworkErrorString (WSAGetLastError ()));
2400
+ LogPrintf (" %s\n " , strError.original );
2401
+ }
2399
2402
2400
2403
// some systems don't have IPV6_V6ONLY but are always v6only; others do have the option
2401
2404
// and enable it by default or not. Try to enable it, if possible.
2402
2405
if (addrBind.IsIPv6 ()) {
2403
2406
#ifdef IPV6_V6ONLY
2404
- setsockopt (sock->Get (), IPPROTO_IPV6, IPV6_V6ONLY, (sockopt_arg_type)&nOne, sizeof (int ));
2407
+ if (sock->SetSockOpt (IPPROTO_IPV6, IPV6_V6ONLY, (sockopt_arg_type)&nOne, sizeof (int )) == SOCKET_ERROR) {
2408
+ strError = strprintf (Untranslated (" Error setting IPV6_V6ONLY on socket: %s, continuing anyway" ), NetworkErrorString (WSAGetLastError ()));
2409
+ LogPrintf (" %s\n " , strError.original );
2410
+ }
2405
2411
#endif
2406
2412
#ifdef WIN32
2407
2413
int nProtLevel = PROTECTION_LEVEL_UNRESTRICTED;
2408
- setsockopt (sock->Get (), IPPROTO_IPV6, IPV6_PROTECTION_LEVEL, (const char *)&nProtLevel, sizeof (int ));
2414
+ if (sock->SetSockOpt (IPPROTO_IPV6, IPV6_PROTECTION_LEVEL, (const char *)&nProtLevel, sizeof (int )) == SOCKET_ERROR) {
2415
+ strError = strprintf (Untranslated (" Error setting IPV6_PROTECTION_LEVEL on socket: %s, continuing anyway" ), NetworkErrorString (WSAGetLastError ()));
2416
+ LogPrintf (" %s\n " , strError.original );
2417
+ }
2409
2418
#endif
2410
2419
}
2411
2420
0 commit comments