Skip to content

Commit

Permalink
Rename ntsi::{Datagram,Stream,Listener}Socket::isBlocking to getBlocking
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrm456 committed Apr 12, 2024
1 parent 4faad11 commit cb8a38d
Show file tree
Hide file tree
Showing 15 changed files with 101 additions and 94 deletions.
8 changes: 4 additions & 4 deletions groups/nts/ntsb/ntsb_datagramsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,14 @@ ntsa::Error DatagramSocket::setBlocking(bool blocking)
return ntsu::SocketOptionUtil::setBlocking(d_handle, blocking);
}

ntsa::Error DatagramSocket::isBlocking(bool* blocking) const
ntsa::Error DatagramSocket::setOption(const ntsa::SocketOption& option)
{
return ntsu::SocketOptionUtil::isBlocking(d_handle, blocking);
return ntsu::SocketOptionUtil::setOption(d_handle, option);
}

ntsa::Error DatagramSocket::setOption(const ntsa::SocketOption& option)
ntsa::Error DatagramSocket::getBlocking(bool* blocking) const
{
return ntsu::SocketOptionUtil::setOption(d_handle, option);
return ntsu::SocketOptionUtil::getBlocking(d_handle, blocking);
}

ntsa::Error DatagramSocket::getOption(ntsa::SocketOption* option,
Expand Down
8 changes: 4 additions & 4 deletions groups/nts/ntsb/ntsb_datagramsocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,14 @@ class DatagramSocket : public ntsi::DatagramSocket
/// according to the specified 'blocking' flag. Return the error.
ntsa::Error setBlocking(bool blocking) BSLS_KEYWORD_OVERRIDE;

/// Request the kernel if the socket is in a blocking mode and load the
/// result in the specified 'blocking' Return the error.
ntsa::Error isBlocking(bool* blocking) const BSLS_KEYWORD_OVERRIDE;

/// Set the specified 'option' for this socket. Return the error.
ntsa::Error setOption(const ntsa::SocketOption& option)
BSLS_KEYWORD_OVERRIDE;

/// Load into the specified 'blocking' flag the blocking mode of the
/// specified 'socket'. Return the error.
ntsa::Error getBlocking(bool* blocking) const BSLS_KEYWORD_OVERRIDE;

/// Load into the specified 'option' the socket option of the specified
/// 'type' set for this socket. Return the error.
ntsa::Error getOption(ntsa::SocketOption* option,
Expand Down
8 changes: 4 additions & 4 deletions groups/nts/ntsb/ntsb_listenersocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,14 @@ ntsa::Error ListenerSocket::setBlocking(bool blocking)
return ntsu::SocketOptionUtil::setBlocking(d_handle, blocking);
}

ntsa::Error ListenerSocket::isBlocking(bool* blocking) const
ntsa::Error ListenerSocket::setOption(const ntsa::SocketOption& option)
{
return ntsu::SocketOptionUtil::isBlocking(d_handle, blocking);
return ntsu::SocketOptionUtil::setOption(d_handle, option);
}

ntsa::Error ListenerSocket::setOption(const ntsa::SocketOption& option)
ntsa::Error ListenerSocket::getBlocking(bool* blocking) const
{
return ntsu::SocketOptionUtil::setOption(d_handle, option);
return ntsu::SocketOptionUtil::getBlocking(d_handle, blocking);
}

ntsa::Error ListenerSocket::getOption(ntsa::SocketOption* option,
Expand Down
8 changes: 4 additions & 4 deletions groups/nts/ntsb/ntsb_listenersocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ class ListenerSocket : public ntsi::ListenerSocket
/// according to the specified 'blocking' flag. Return the error.
ntsa::Error setBlocking(bool blocking) BSLS_KEYWORD_OVERRIDE;

/// Request the kernel if the socket is in a blocking mode and load the
/// result in the specified 'blocking' Return the error.
ntsa::Error isBlocking(bool* blocking) const BSLS_KEYWORD_OVERRIDE;

/// Set the specified 'option' for this socket. Return the error.
ntsa::Error setOption(const ntsa::SocketOption& option)
BSLS_KEYWORD_OVERRIDE;

/// Load into the specified 'blocking' flag the blocking mode of the
/// specified 'socket'. Return the error.
ntsa::Error getBlocking(bool* blocking) const BSLS_KEYWORD_OVERRIDE;

/// Load into the specified 'option' the socket option of the specified
/// 'type' set for this socket. Return the error.
ntsa::Error getOption(ntsa::SocketOption* option,
Expand Down
8 changes: 4 additions & 4 deletions groups/nts/ntsb/ntsb_streamsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,14 @@ ntsa::Error StreamSocket::setBlocking(bool blocking)
return ntsu::SocketOptionUtil::setBlocking(d_handle, blocking);
}

ntsa::Error StreamSocket::isBlocking(bool* blocking) const
ntsa::Error StreamSocket::setOption(const ntsa::SocketOption& option)
{
return ntsu::SocketOptionUtil::isBlocking(d_handle, blocking);
return ntsu::SocketOptionUtil::setOption(d_handle, option);
}

ntsa::Error StreamSocket::setOption(const ntsa::SocketOption& option)
ntsa::Error StreamSocket::getBlocking(bool* blocking) const
{
return ntsu::SocketOptionUtil::setOption(d_handle, option);
return ntsu::SocketOptionUtil::getBlocking(d_handle, blocking);
}

ntsa::Error StreamSocket::getOption(ntsa::SocketOption* option,
Expand Down
8 changes: 4 additions & 4 deletions groups/nts/ntsb/ntsb_streamsocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,14 @@ class StreamSocket : public ntsi::StreamSocket
/// according to the specified 'blocking' flag. Return the error.
ntsa::Error setBlocking(bool blocking) BSLS_KEYWORD_OVERRIDE;

/// Request the kernel if the socket is in a blocking mode and load the
/// result in the specified 'blocking' Return the error.
ntsa::Error isBlocking(bool* blocking) const BSLS_KEYWORD_OVERRIDE;

/// Set the specified 'option' for this socket. Return the error.
ntsa::Error setOption(const ntsa::SocketOption& option)
BSLS_KEYWORD_OVERRIDE;

/// Load into the specified 'blocking' flag the blocking mode of the
/// specified 'socket'. Return the error.
ntsa::Error getBlocking(bool* blocking) const BSLS_KEYWORD_OVERRIDE;

/// Load into the specified 'option' the socket option of the specified
/// 'type' set for this socket. Return the error.
ntsa::Error getOption(ntsa::SocketOption* option,
Expand Down
9 changes: 4 additions & 5 deletions groups/nts/ntsi/ntsi_datagramsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,16 @@ ntsa::Error DatagramSocket::setBlocking(bool blocking)
return ntsa::Error(ntsa::Error::e_NOT_IMPLEMENTED);
}

ntsa::Error DatagramSocket::isBlocking(bool* blocking) const
ntsa::Error DatagramSocket::setOption(const ntsa::SocketOption& option)
{
NTSCFG_WARNING_UNUSED(blocking);
NTSCFG_WARNING_UNUSED(option);

return ntsa::Error(ntsa::Error::e_NOT_IMPLEMENTED);
}

ntsa::Error DatagramSocket::setOption(const ntsa::SocketOption& option)
ntsa::Error DatagramSocket::getBlocking(bool* blocking) const
{
NTSCFG_WARNING_UNUSED(option);

*blocking = false;
return ntsa::Error(ntsa::Error::e_NOT_IMPLEMENTED);
}

Expand Down
8 changes: 4 additions & 4 deletions groups/nts/ntsi/ntsi_datagramsocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -571,13 +571,13 @@ class DatagramSocket : public ntsi::Channel
/// according to the specified 'blocking' flag. Return the error.
virtual ntsa::Error setBlocking(bool blocking);

/// If the socket is in a blocking mode then load true in the specified
/// 'blocking', otherwise load false. Return the error.
virtual ntsa::Error isBlocking(bool* blocking) const;

/// Set the specified 'option' for this socket. Return the error.
virtual ntsa::Error setOption(const ntsa::SocketOption& option);

/// Load into the specified 'blocking' flag the blocking mode of the
/// specified 'socket'. Return the error.
virtual ntsa::Error getBlocking(bool* blocking) const;

/// Load into the specified 'option' the socket option of the specified
/// 'type' set for this socket. Return the error.
virtual ntsa::Error getOption(ntsa::SocketOption* option,
Expand Down
9 changes: 4 additions & 5 deletions groups/nts/ntsi/ntsi_listenersocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,16 @@ ntsa::Error ListenerSocket::setBlocking(bool blocking)
return ntsa::Error(ntsa::Error::e_NOT_IMPLEMENTED);
}

ntsa::Error ListenerSocket::isBlocking(bool* blocking) const
ntsa::Error ListenerSocket::setOption(const ntsa::SocketOption& option)
{
NTSCFG_WARNING_UNUSED(blocking);
NTSCFG_WARNING_UNUSED(option);

return ntsa::Error(ntsa::Error::e_NOT_IMPLEMENTED);
}

ntsa::Error ListenerSocket::setOption(const ntsa::SocketOption& option)
ntsa::Error ListenerSocket::getBlocking(bool* blocking) const
{
NTSCFG_WARNING_UNUSED(option);

*blocking = false;
return ntsa::Error(ntsa::Error::e_NOT_IMPLEMENTED);
}

Expand Down
8 changes: 4 additions & 4 deletions groups/nts/ntsi/ntsi_listenersocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ class ListenerSocket : public ntsi::Descriptor
/// according to the specified 'blocking' flag. Return the error.
virtual ntsa::Error setBlocking(bool blocking);

/// If the socket is in a blocking mode then load true in the specified
/// 'blocking', otherwise load false. Return the error.
virtual ntsa::Error isBlocking(bool* blocking) const;

/// Set the specified 'option' for this socket. Return the error.
virtual ntsa::Error setOption(const ntsa::SocketOption& option);

/// Load into the specified 'blocking' flag the blocking mode of the
/// specified 'socket'. Return the error.
virtual ntsa::Error getBlocking(bool* blocking) const;

/// Load into the specified 'option' the socket option of the specified
/// 'type' set for this socket. Return the error.
virtual ntsa::Error getOption(ntsa::SocketOption* option,
Expand Down
9 changes: 4 additions & 5 deletions groups/nts/ntsi/ntsi_streamsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,16 @@ ntsa::Error StreamSocket::setBlocking(bool blocking)
return ntsa::Error(ntsa::Error::e_NOT_IMPLEMENTED);
}

ntsa::Error StreamSocket::isBlocking(bool* blocking) const
ntsa::Error StreamSocket::setOption(const ntsa::SocketOption& option)
{
NTSCFG_WARNING_UNUSED(blocking);
NTSCFG_WARNING_UNUSED(option);

return ntsa::Error(ntsa::Error::e_NOT_IMPLEMENTED);
}

ntsa::Error StreamSocket::setOption(const ntsa::SocketOption& option)
ntsa::Error StreamSocket::getBlocking(bool* blocking) const
{
NTSCFG_WARNING_UNUSED(option);

*blocking = false;
return ntsa::Error(ntsa::Error::e_NOT_IMPLEMENTED);
}

Expand Down
8 changes: 4 additions & 4 deletions groups/nts/ntsi/ntsi_streamsocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,13 @@ class StreamSocket : public ntsi::Channel
/// according to the specified 'blocking' flag. Return the error.
virtual ntsa::Error setBlocking(bool blocking);

/// If the socket is in a blocking mode then load true in the specified
/// 'blocking', otherwise load false. Return the error.
virtual ntsa::Error isBlocking(bool* blocking) const;

/// Set the specified 'option' for this socket. Return the error.
virtual ntsa::Error setOption(const ntsa::SocketOption& option);

/// Load into the specified 'blocking' flag the blocking mode of the
/// specified 'socket'. Return the error.
virtual ntsa::Error getBlocking(bool* blocking) const;

/// Load into the specified 'option' the socket option of the specified
/// 'type' set for this socket. Return the error.
virtual ntsa::Error getOption(ntsa::SocketOption* option,
Expand Down
41 changes: 22 additions & 19 deletions groups/nts/ntsu/ntsu_socketoptionutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,18 +348,6 @@ ntsa::Error SocketOptionUtil::setBlocking(ntsa::Handle socket, bool blocking)
return ntsa::Error();
}

ntsa::Error SocketOptionUtil::isBlocking(ntsa::Handle socket, bool* blocking)
{
const int flags = fcntl(socket, F_GETFL, 0);
if (flags < 0) {
return ntsa::Error(errno);
}

*blocking = ((flags & O_NONBLOCK) == 0);

return ntsa::Error();
}

ntsa::Error SocketOptionUtil::setKeepAlive(ntsa::Handle socket, bool keepAlive)
{
int optionValue = static_cast<int>(keepAlive);
Expand Down Expand Up @@ -774,6 +762,20 @@ ntsa::Error SocketOptionUtil::setZeroCopy(ntsa::Handle socket, bool zeroCopy)
#endif
}

ntsa::Error SocketOptionUtil::getBlocking(ntsa::Handle socket, bool* blocking)
{
*blocking = false;

const int flags = fcntl(socket, F_GETFL, 0);
if (flags < 0) {
return ntsa::Error(errno);
}

*blocking = ((flags & O_NONBLOCK) == 0);

return ntsa::Error();
}

ntsa::Error SocketOptionUtil::getKeepAlive(bool* keepAlive,
ntsa::Handle socket)
{
Expand Down Expand Up @@ -1990,13 +1992,6 @@ ntsa::Error SocketOptionUtil::setBlocking(ntsa::Handle socket, bool blocking)
return ntsa::Error();
}

ntsa::Error SocketOptionUtil::isBlocking(ntsa::Handle socket, bool* blocking)
{
NTSCFG_WARNING_UNUSED(socket);
NTSCFG_WARNING_UNUSED(blocking);
return ntsa::Error(ntsa::Error::e_NOT_IMPLEMENTED);
}

ntsa::Error SocketOptionUtil::setKeepAlive(ntsa::Handle socket, bool keepAlive)
{
BOOL optionValue = static_cast<BOOL>(keepAlive);
Expand Down Expand Up @@ -2240,6 +2235,14 @@ ntsa::Error SocketOptionUtil::setInlineOutOfBandData(ntsa::Handle socket,
return ntsa::Error();
}

ntsa::Error SocketOptionUtil::getBlocking(ntsa::Handle socket, bool* blocking)
{
NTSCFG_WARNING_UNUSED(socket);

*blocking = false;
return ntsa::Error(ntsa::Error::e_NOT_IMPLEMENTED);
}

ntsa::Error SocketOptionUtil::getKeepAlive(bool* keepAlive,
ntsa::Handle socket)
{
Expand Down
16 changes: 9 additions & 7 deletions groups/nts/ntsu/ntsu_socketoptionutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ struct SocketOptionUtil {
/// according to the specified 'blocking' flag. Return the error.
static ntsa::Error setBlocking(ntsa::Handle socket, bool blocking);

/// If the specified 'socket' is in a blocking mode then load true in the
/// specified 'blocking', otherwise load false. Return the error.
static ntsa::Error isBlocking(ntsa::Handle handle, bool* blocking);

/// Set the option for the specified 'socket' that controls automatic
/// periodic transmission of TCP keep-alive packets according to the
/// specified 'keepAlive' flag. Return the error.
Expand Down Expand Up @@ -152,6 +148,12 @@ struct SocketOptionUtil {
ntsa::SocketOptionType::Value type,
ntsa::Handle socket);

/// Load into the specified 'blocking' flag the blocking mode of the
/// specified 'socket'. Return the error. Note that this function always
/// returns an error on Windows, as determination of the blocking mode is
/// not supported on that platform.
static ntsa::Error getBlocking(ntsa::Handle handle, bool* blocking);

/// Load into the specified 'keepAlive' flag the option for the
/// specified 'socket' that controls automatic periodic transmission
/// of TCP keep-alive packets. Return the error.
Expand Down Expand Up @@ -298,15 +300,15 @@ struct SocketOptionUtil {
static ntsa::Error isLocal(bool* result, ntsa::Handle socket);

/// Return true if the specified 'socket' supports notifications, otherwise
/// return false.
/// return false.
static bool supportsNotifications(ntsa::Handle socket);

/// Return true if the specified 'socket' supports timestamping, otherwise
/// return false.
/// return false.
static bool supportsTimestamping(ntsa::Handle socket);

/// Return true if the specified 'socket' supports zero-copy, otherwise
/// return false.
/// return false.
static bool supportsZeroCopy(ntsa::Handle socket);

};
Expand Down
Loading

0 comments on commit cb8a38d

Please sign in to comment.