1#ifndef NET_SocketHandle_h__
2#define NET_SocketHandle_h__
37 template<
class Socket>
41 friend class TCPSocket;
42 friend class SCTPSocket;
43 friend class UnixStreamSocket;
61 reset(other.release());
75 explicit operator bool() const noexcept {
return m_sockfd >= 0; }
79 explicit SocketHandle(
int sockfd) noexcept : m_sockfd(sockfd) {}
82 int release() noexcept
90 void reset(
int fd = -1) noexcept
94 if( m_sockfd >= 0) ::close(m_sockfd);
A simple class to provide strict ownership of socket handles.
SocketHandle(SocketHandle &&other) noexcept
move constructor: transfers ownership from other
SocketHandle & operator=(SocketHandle &&other) noexcept
move assignment: closes the currently owned descriptor first
SocketHandle() noexcept
constructs an invalid socket handle
Unix domain stream socket class.