mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
moveonly: move IsSelectableSocket() from compat.h to sock.{h,cpp}
To be converted to a method of the `Sock` class.
This commit is contained in:
parent
5c82ca3365
commit
5db7d2ca0a
3 changed files with 10 additions and 8 deletions
|
@ -109,14 +109,6 @@ typedef char* sockopt_arg_type;
|
||||||
#define USE_POLL
|
#define USE_POLL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool static inline IsSelectableSocket(const SOCKET& s) {
|
|
||||||
#if defined(USE_POLL) || defined(WIN32)
|
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
return (s < FD_SETSIZE);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// MSG_NOSIGNAL is not available on some platforms, if it doesn't exist define it as 0
|
// MSG_NOSIGNAL is not available on some platforms, if it doesn't exist define it as 0
|
||||||
#if !defined(MSG_NOSIGNAL)
|
#if !defined(MSG_NOSIGNAL)
|
||||||
#define MSG_NOSIGNAL 0
|
#define MSG_NOSIGNAL 0
|
||||||
|
|
|
@ -117,6 +117,14 @@ int Sock::GetSockName(sockaddr* name, socklen_t* name_len) const
|
||||||
return getsockname(m_socket, name, name_len);
|
return getsockname(m_socket, name, name_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsSelectableSocket(const SOCKET& s) {
|
||||||
|
#if defined(USE_POLL) || defined(WIN32)
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return (s < FD_SETSIZE);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
bool Sock::Wait(std::chrono::milliseconds timeout, Event requested, Event* occurred) const
|
bool Sock::Wait(std::chrono::milliseconds timeout, Event requested, Event* occurred) const
|
||||||
{
|
{
|
||||||
// We need a `shared_ptr` owning `this` for `WaitMany()`, but don't want
|
// We need a `shared_ptr` owning `this` for `WaitMany()`, but don't want
|
||||||
|
|
|
@ -267,6 +267,8 @@ private:
|
||||||
void Close();
|
void Close();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool IsSelectableSocket(const SOCKET& s);
|
||||||
|
|
||||||
/** Return readable error string for a network error code */
|
/** Return readable error string for a network error code */
|
||||||
std::string NetworkErrorString(int err);
|
std::string NetworkErrorString(int err);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue