Class Socket#
Defined in File Socket.h
Inheritance Relationships#
Derived Types#
public TRAP::Network::TCPListener
(Class TCPListener)public TRAP::Network::TCPListenerIPv6
(Class TCPListenerIPv6)public TRAP::Network::TCPSocket
(Class TCPSocket)public TRAP::Network::TCPSocketIPv6
(Class TCPSocketIPv6)public TRAP::Network::UDPSocket
(Class UDPSocket)public TRAP::Network::UDPSocketIPv6
(Class UDPSocketIPv6)
Class Documentation#
-
class Socket#
Subclassed by TRAP::Network::TCPListener, TRAP::Network::TCPListenerIPv6, TRAP::Network::TCPSocket, TRAP::Network::TCPSocketIPv6, TRAP::Network::UDPSocket, TRAP::Network::UDPSocketIPv6
Public Types
Public Functions
-
constexpr Socket() noexcept = default#
Constructor.
-
virtual ~Socket()#
Destructor.
-
void SetBlocking(bool blocking)#
Set the blocking state of the socket.
In blocking mode, calls will not return until they have completed their task. For example, a call to receive in blocking mode won’t return until some data was actually received. In non-blocking mode, calls will always return immediately, using the return code to signal whether there was data available or not. By default, all sockets are blocking.
- Parameters:
blocking – True to set the socket as blocking, false for non-blocking.
-
constexpr bool IsBlocking() const noexcept#
Tell whether the socket is in blocking or non-blocking mode.
- Returns:
True if the socket is blocking, false otherwise.
Protected Types
Protected Functions
-
explicit constexpr Socket(Type type) noexcept#
Constructor.
This constructor can only be accessed by derived classes.
- Parameters:
type – Type of the socket (TCP or UDP).
-
constexpr SocketHandle GetHandle() const noexcept#
Return the internal handle of the socket.
The returned handle may be invalid if the socket was not created yet (or already destroyed). This function can only be accessed by derived classes.
- Returns:
The internal (OS-specific) handle of the socket.
-
void CreateIPv4()#
Create the internal representation of the socket.
This function can only be accessed by derived classes.
-
void CreateIPv6()#
Create the internal representation of the socket.
This function can only be accessed by derived classes.
-
void Create(SocketHandle handle)#
Create the internal representation of the socket from a socket handle.
This function can only be accessed by derived classes.
- Parameters:
handle – OS-specific handle of the socket to wrap.
-
void Close()#
Close the socket gracefully.
This function can only be accessed by derived classes.
-
constexpr Socket() noexcept = default#