Class TCPSocketIPv6#
Defined in File TCPSocketIPv6.h
Nested Relationships#
Nested Types#
Inheritance Relationships#
Base Type#
public TRAP::Network::Socket
(Class Socket)
Class Documentation#
-
class TCPSocketIPv6 : public TRAP::Network::Socket#
Specialized socket using the TCP protocol.
Public Functions
-
constexpr TCPSocketIPv6() noexcept#
Constructor.
-
consteval TCPSocketIPv6(const TCPSocketIPv6&) = delete#
Copy constructor.
-
consteval TCPSocketIPv6 &operator=(const TCPSocketIPv6&) = delete#
Copy assignment operator.
-
constexpr TCPSocketIPv6(TCPSocketIPv6&&) noexcept = default#
Move constructor.
-
TCPSocketIPv6 &operator=(TCPSocketIPv6&&) noexcept = default#
Move assignment operator.
-
~TCPSocketIPv6() override = default#
Destructor.
-
u16 GetLocalPort() const#
Get the port to which the socket is bound locally.
If the socket is not connected, this function returns 0.
- Returns:
Port to which the socket is bound.
-
IPv6Address GetRemoteAddress() const#
Get the address of the connected peer.
If the socket is not connected, this function returns TRAP::Network::IPv4Address::None.
- Returns:
Address of the remote peer.
-
u16 GetRemotePort() const#
Get the port of the connected peer to which the socket is connected.
If the socket is not connected, this function returns 0.
- Returns:
Remote port to which the socket is connected.
-
Status Connect(const IPv6Address &remoteAddress, u16 remotePort, Utils::TimeStep timeout = Utils::TimeStep(0.0f))#
Connect the socket to a remote peer.
In blocking mode, this function may take a while, especially if the remote peer is not reachable. The last parameter allows you to stop trying to connect after a given timeout. If the socket is already connected, the connection is forcibly disconnected before attempting to connect again.
- Parameters:
remoteAddress – Address of the remote peer.
remotePort – Port of the remote peer.
timeout – Optional maximum time to wait.
- Returns:
Status code.
-
void Disconnect()#
Disconnect the socket from its remote peer.
This function gracefully closes the connection. If the socket is not connected, this function has no effect.
-
Status Send(const void *data, usize size) const#
Send raw data to the remote peer.
To be able to handle partial sends over non-blocking sockets, use the Send(const void*, usize, usize&) overload instead. This function will fail if the socket is not connected.
- Parameters:
data – Pointer to the sequence of bytes to send.
size – Number of bytes to send.
- Returns:
Status code.
-
Status Send(const void *data, usize size, usize &sent) const#
Send raw data to the remote peer.
This function will fail if the socket is not connected
- Parameters:
data – Pointer to the sequence of bytes to send.
size – Number of bytes to send.
sent – The number of bytes sent will be written here.
- Returns:
Status code.
-
Status Receive(void *data, usize size, usize &received) const#
Receive raw data from the remote peer.
In blocking mode, this function will wait until some bytes are actually received. This function will fail if the socket is not connected.
- Parameters:
data – Pointer to the array to fill with the received bytes.
size – Maximum number of bytes that can be received.
received – This variable is filled with the actual number of bytes received.
- Returns:
Status code.
-
Status Send(Packet &packet) const#
Send a formatted packet of data to the remote peer.
In non-blocking mode, if this function returns TRAP::Network::Socket::Status::Partial, you must retry sending the same unmodified packet before sending anything else in order to guarantee the packet arrives at the remote peer uncorrupted. This function will fail if the socket is not connected.
- Parameters:
packet – Packet to send.
- Returns:
Status code.
-
Status Receive(Packet &packet)#
Receive a formatted packet of data from the remote peer.
In blocking mode, this function will wait until the whole packet has been received. This function will fail if the socket is not connected.
- Parameters:
packet – Packet to fill with the received data.
- Returns:
Status code.
-
constexpr TCPSocketIPv6() noexcept#