diff --git a/src/net/SocketDescriptor.cxx b/src/net/SocketDescriptor.cxx index c6846c6d0..11624a2d4 100644 --- a/src/net/SocketDescriptor.cxx +++ b/src/net/SocketDescriptor.cxx @@ -32,6 +32,16 @@ SocketDescriptor::IsStream() const noexcept return GetType() == SOCK_STREAM; } +#ifndef _WIN32 + +int +SocketDescriptor::GetProtocol() const noexcept +{ + return GetIntOption(SOL_SOCKET, SO_PROTOCOL, -1); +} + +#endif // !_WIN32 + #ifdef _WIN32 void diff --git a/src/net/SocketDescriptor.hxx b/src/net/SocketDescriptor.hxx index 0f90fb9d5..a25641c0c 100644 --- a/src/net/SocketDescriptor.hxx +++ b/src/net/SocketDescriptor.hxx @@ -101,6 +101,15 @@ public: [[gnu::pure]] bool IsStream() const noexcept; +#ifndef _WIN32 + /** + * Determine the socket protocol (SO_PROTOCOL), + * e.g. IPPROTO_SCTP. Returns -1 on error. + */ + [[gnu::pure]] + int GetProtocol() const noexcept; +#endif // !_WIN32 + static constexpr SocketDescriptor Undefined() noexcept { #ifdef _WIN32 return SocketDescriptor{INVALID_SOCKET};