connection layer for TCP connection management.
More...
#include <TcpConnection.h>
Inherits AzNetworking::IConnection.
|
| TcpConnection (ConnectionId connectionId, const IpAddress &remoteAddress, TcpNetworkInterface &networkInterface, TcpSocket &socket) |
|
| TcpConnection (ConnectionId connectionId, const IpAddress &remoteAddress, TcpNetworkInterface &networkInterface, TrustZone trustZone, bool useEncryption) |
|
TcpSocket * | GetTcpSocket () const |
|
bool | IsOpen () const |
|
bool | Connect (uint16_t localPort) |
|
void | UpdateSend () |
| Handles any new outgoing network traffic.
|
|
bool | UpdateRecv () |
|
bool | SendReliablePacket (const IPacket &packet) override |
| IConnection interface.
|
|
PacketId | SendUnreliablePacket (const IPacket &packet) override |
|
bool | WasPacketAcked (PacketId packetId) const override |
|
ConnectionState | GetConnectionState () const override |
|
ConnectionRole | GetConnectionRole () const override |
|
bool | Disconnect (DisconnectReason reason, TerminationEndpoint endpoint) override |
|
void | SetConnectionMtu (uint32_t connectionMtu) override |
|
uint32_t | GetConnectionMtu () const override |
|
void | SetRegisteredSocketFd (SocketFd registeredSocketFd) |
|
SocketFd | GetRegisteredSocketFd () const |
|
| IConnection (ConnectionId connectionId, const IpAddress &address) |
|
virtual bool | SendReliablePacket (const IPacket &packet)=0 |
|
virtual PacketId | SendUnreliablePacket (const IPacket &packet)=0 |
|
virtual bool | WasPacketAcked (PacketId packetId) const =0 |
|
virtual ConnectionState | GetConnectionState () const =0 |
|
virtual ConnectionRole | GetConnectionRole () const =0 |
|
virtual bool | Disconnect (DisconnectReason reason, TerminationEndpoint endpoint)=0 |
|
virtual void | SetConnectionMtu (uint32_t connectionMtu)=0 |
|
virtual uint32_t | GetConnectionMtu () const =0 |
|
ConnectionId | GetConnectionId () const |
|
void | SetUserData (void *userData) |
|
void * | GetUserData () const |
|
void | SetRemoteAddress (const IpAddress &address) |
|
const IpAddress & | GetRemoteAddress () const |
|
const ConnectionMetrics & | GetMetrics () const |
|
ConnectionMetrics & | GetMetrics () |
|
const ConnectionQuality & | GetConnectionQuality () const |
|
ConnectionQuality & | GetConnectionQuality () |
|
connection layer for TCP connection management.
◆ TcpConnection() [1/2]
Construct with an existing socket, used when accepting an incoming connection
- Parameters
-
connectionId | connection identifier of this connection instance |
remoteAddress | IP address of the remote endpoint |
networkInterface | TcpNetworkInterface that owns this connection instance |
socket | TCP socket to take ownership of and use for sending and receiving data |
◆ TcpConnection() [2/2]
AzNetworking::TcpConnection::TcpConnection |
( |
ConnectionId |
connectionId, |
|
|
const IpAddress & |
remoteAddress, |
|
|
TcpNetworkInterface & |
networkInterface, |
|
|
TrustZone |
trustZone, |
|
|
bool |
useEncryption |
|
) |
| |
Construct a new socket with optional encryption, used when initiating a new connection
- Parameters
-
connectionId | connection identifier of this connection instance |
remoteAddress | IP address of the remote endpoint |
networkInterface | TcpNetworkInterface that owns this connection instance |
trustZone | for encrypted connections, the level of trust we associate with this connection (internal or external) |
useEncryption | if true connections will be made over TLS |
◆ Connect()
bool AzNetworking::TcpConnection::Connect |
( |
uint16_t |
localPort | ) |
|
Connects to the provided remote address.
- Parameters
-
localPort | the local port to open a connection from, 0 binds to any available port |
- Returns
- boolean true on success
◆ Disconnect()
bool AzNetworking::TcpConnection::Disconnect |
( |
DisconnectReason |
reason, |
|
|
TerminationEndpoint |
endpoint |
|
) |
| |
|
overridevirtual |
Disconnects the connection with the provided termination reason
- Parameters
-
reason | reason for the disconnect |
endpoint | which endpoint initiated the disconnect, local or remote |
- Returns
- boolean true on success
Implements AzNetworking::IConnection.
◆ GetConnectionMtu()
uint32_t AzNetworking::TcpConnection::GetConnectionMtu |
( |
| ) |
const |
|
overridevirtual |
Returns the connection maximum transmission unit. Currently unsupported on TcpConnections
- Returns
- the max transmission unit for this connection
Implements AzNetworking::IConnection.
◆ GetConnectionRole()
ConnectionRole AzNetworking::TcpConnection::GetConnectionRole |
( |
| ) |
const |
|
overridevirtual |
Retrieves the connection role of this connection instance, whether it was initiated or accepted.
- Returns
- whether this connection was initiated or accepted
Implements AzNetworking::IConnection.
◆ GetConnectionState()
ConnectionState AzNetworking::TcpConnection::GetConnectionState |
( |
| ) |
const |
|
overridevirtual |
◆ GetRegisteredSocketFd()
SocketFd AzNetworking::TcpConnection::GetRegisteredSocketFd |
( |
| ) |
const |
|
inline |
Returns the socket file descriptor for this TcpConnection in the associated ConnectionSet instance.
- Returns
- the socket file descriptor for this TcpConnection in the associated ConnectionSet instance
◆ GetTcpSocket()
TcpSocket * AzNetworking::TcpConnection::GetTcpSocket |
( |
| ) |
const |
|
inline |
◆ IsOpen()
bool AzNetworking::TcpConnection::IsOpen |
( |
| ) |
const |
|
inline |
Returns true if this connection instance is in an open state, and is capable of actively sending and receiving packets.
- Returns
- boolean true if this connection instance is in an open state
◆ SendReliablePacket()
bool AzNetworking::TcpConnection::SendReliablePacket |
( |
const IPacket & |
packet | ) |
|
|
overridevirtual |
◆ SendUnreliablePacket()
PacketId AzNetworking::TcpConnection::SendUnreliablePacket |
( |
const IPacket & |
packet | ) |
|
|
overridevirtual |
A helper function that transmits a packet on this connection unreliably.
- Parameters
-
- Returns
- the unreliable packet identifier of the transmitted packet
Implements AzNetworking::IConnection.
◆ SetConnectionMtu()
void AzNetworking::TcpConnection::SetConnectionMtu |
( |
uint32_t |
connectionMtu | ) |
|
|
overridevirtual |
Sets connection maximum transmission unit for this connection. Currently unsupported on TcpConnections
- Parameters
-
connectionMtu | the max transmission unit for this connection |
Implements AzNetworking::IConnection.
◆ SetRegisteredSocketFd()
void AzNetworking::TcpConnection::SetRegisteredSocketFd |
( |
SocketFd |
registeredSocketFd | ) |
|
|
inline |
Sets the registered socket file descriptor for this TcpConnection in the associated ConnectionSet instance.
- Parameters
-
registeredSocketFd | the socket file descriptor for this TcpConnection in the associated ConnectionSet instance |
◆ UpdateRecv()
bool AzNetworking::TcpConnection::UpdateRecv |
( |
| ) |
|
Handles any new incoming network traffic.
- Returns
- boolean true if the socket is still active, false if it has been remotely terminated
◆ WasPacketAcked()
bool AzNetworking::TcpConnection::WasPacketAcked |
( |
PacketId |
packetId | ) |
const |
|
overridevirtual |
Returns true if the given packet id was confirmed acknowledged by the remote endpoint, false otherwise.
- Parameters
-
packetId | the packet id of the packet to confirm acknowledgment of |
- Returns
- boolean true if the packet is confirmed acknowledged, false if the packet number is out of range, lost, or still pending acknowledgment
Implements AzNetworking::IConnection.
The documentation for this class was generated from the following files:
- Code/Framework/AzNetworking/AzNetworking/TcpTransport/TcpConnection.h
- Code/Framework/AzNetworking/AzNetworking/TcpTransport/TcpConnection.inl