Skip to content

Commit

Permalink
net/SocketDescriptor: SO_PROTOCOL is really Linux-specific
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Dec 9, 2023
1 parent 9347851 commit 14ea2dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/net/SocketDescriptor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ SocketDescriptor::IsStream() const noexcept
return GetType() == SOCK_STREAM;
}

#ifdef __linux__

int
SocketDescriptor::GetProtocol() const noexcept
{
return GetIntOption(SOL_SOCKET, SO_PROTOCOL, -1);
}

#endif // __linux__

#ifdef _WIN32

void
Expand Down
2 changes: 2 additions & 0 deletions src/net/SocketDescriptor.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,14 @@ public:
[[gnu::pure]]
bool IsStream() const noexcept;

#ifdef __linux__
/**
* Determine the socket protocol (SO_PROTOCOL),
* e.g. IPPROTO_SCTP. Returns -1 on error.
*/
[[gnu::pure]]
int GetProtocol() const noexcept;
#endif // __linux__

static constexpr SocketDescriptor Undefined() noexcept {
#ifdef _WIN32
Expand Down

0 comments on commit 14ea2dd

Please sign in to comment.