Skip to content

Commit

Permalink
Support detection of file descriptor blocking mode on Unixes
Browse files Browse the repository at this point in the history
  • Loading branch information
smtrfnv authored Apr 12, 2024
1 parent fe4a079 commit b9e5d3c
Show file tree
Hide file tree
Showing 15 changed files with 221 additions and 44 deletions.
5 changes: 5 additions & 0 deletions groups/nts/ntsb/ntsb_datagramsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ ntsa::Error DatagramSocket::setBlocking(bool blocking)
return ntsu::SocketOptionUtil::setBlocking(d_handle, blocking);
}

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

ntsa::Error DatagramSocket::setOption(const ntsa::SocketOption& option)
{
return ntsu::SocketOptionUtil::setOption(d_handle, option);
Expand Down
4 changes: 4 additions & 0 deletions groups/nts/ntsb/ntsb_datagramsocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ 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;
Expand Down
5 changes: 5 additions & 0 deletions groups/nts/ntsb/ntsb_listenersocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ ntsa::Error ListenerSocket::setBlocking(bool blocking)
return ntsu::SocketOptionUtil::setBlocking(d_handle, blocking);
}

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

ntsa::Error ListenerSocket::setOption(const ntsa::SocketOption& option)
{
return ntsu::SocketOptionUtil::setOption(d_handle, option);
Expand Down
4 changes: 4 additions & 0 deletions groups/nts/ntsb/ntsb_listenersocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ 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;
Expand Down
5 changes: 5 additions & 0 deletions groups/nts/ntsb/ntsb_streamsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ ntsa::Error StreamSocket::setBlocking(bool blocking)
return ntsu::SocketOptionUtil::setBlocking(d_handle, blocking);
}

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

ntsa::Error StreamSocket::setOption(const ntsa::SocketOption& option)
{
return ntsu::SocketOptionUtil::setOption(d_handle, option);
Expand Down
4 changes: 4 additions & 0 deletions groups/nts/ntsb/ntsb_streamsocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ 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;
Expand Down
7 changes: 7 additions & 0 deletions groups/nts/ntsi/ntsi_datagramsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ ntsa::Error DatagramSocket::setBlocking(bool blocking)
return ntsa::Error(ntsa::Error::e_NOT_IMPLEMENTED);
}

ntsa::Error DatagramSocket::isBlocking(bool* blocking) const
{
NTSCFG_WARNING_UNUSED(blocking);

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

ntsa::Error DatagramSocket::setOption(const ntsa::SocketOption& option)
{
NTSCFG_WARNING_UNUSED(option);
Expand Down
4 changes: 4 additions & 0 deletions groups/nts/ntsi/ntsi_datagramsocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,10 @@ 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);

Expand Down
7 changes: 7 additions & 0 deletions groups/nts/ntsi/ntsi_listenersocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ ntsa::Error ListenerSocket::setBlocking(bool blocking)
return ntsa::Error(ntsa::Error::e_NOT_IMPLEMENTED);
}

ntsa::Error ListenerSocket::isBlocking(bool* blocking) const
{
NTSCFG_WARNING_UNUSED(blocking);

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

ntsa::Error ListenerSocket::setOption(const ntsa::SocketOption& option)
{
NTSCFG_WARNING_UNUSED(option);
Expand Down
4 changes: 4 additions & 0 deletions groups/nts/ntsi/ntsi_listenersocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ 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);

Expand Down
7 changes: 7 additions & 0 deletions groups/nts/ntsi/ntsi_streamsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ ntsa::Error StreamSocket::setBlocking(bool blocking)
return ntsa::Error(ntsa::Error::e_NOT_IMPLEMENTED);
}

ntsa::Error StreamSocket::isBlocking(bool* blocking) const
{
NTSCFG_WARNING_UNUSED(blocking);

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

ntsa::Error StreamSocket::setOption(const ntsa::SocketOption& option)
{
NTSCFG_WARNING_UNUSED(option);
Expand Down
4 changes: 4 additions & 0 deletions groups/nts/ntsi/ntsi_streamsocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ 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);

Expand Down
Loading

0 comments on commit b9e5d3c

Please sign in to comment.