Class netWorth::NetworkingInterface
ClassList > netWorth > NetworkingInterface
Inherits the following classes: InterfaceBase
Inherited by the following classes: netWorth::ClientInterface, netWorth::ServerInterface
Public Functions
Type | Name |
---|---|
NetworkingInterface (size_t id, const std::string & name) the destination port of the machine this communicates with |
|
virtual bool | bindSocket (UdpSocket & socket, unsigned short port) |
virtual UdpSocket * | getSocket () |
virtual bool | receivePacket (Packet & pkt, std::optional< IpAddress > & sender, unsigned short & port) |
virtual bool | sendPacket (Packet packet, IpAddress destAddr, const unsigned short port) |
Protected Attributes
Type | Name |
---|---|
std::optional< IpAddress > | m_ip The socket we are going to make our connection. |
unsigned short | m_port = = 0 the destination IP of the machine this communicates with |
UdpSocket | m_socket |
Public Functions Documentation
function NetworkingInterface
the destination port of the machine this communicates with
inline netWorth::NetworkingInterface::NetworkingInterface (
size_t id,
const std::string & name
)
Default constructor (AgentBase)
Parameters:
id
agent IDname
agent name
function bindSocket
inline virtual bool netWorth::NetworkingInterface::bindSocket (
UdpSocket & socket,
unsigned short port
)
Bind socket to port number
Parameters:
socket
Socket to be boundport
Port number
Returns:
true if successful
function getSocket
inline virtual UdpSocket * netWorth::NetworkingInterface::getSocket ()
Receives a socket that has been connected between client and server
Returns:
the udp socket
function receivePacket
inline virtual bool netWorth::NetworkingInterface::receivePacket (
Packet & pkt,
std::optional< IpAddress > & sender,
unsigned short & port
)
Starts the connection by receiving the first packet
Parameters:
sender
IP of sending machineport
port number of sending machine
Returns:
received packet
function sendPacket
inline virtual bool netWorth::NetworkingInterface::sendPacket (
Packet packet,
IpAddress destAddr,
const unsigned short port
)
Sends a packet across the socket
Parameters:
packet
the packet we want to senddestAddr
the destination address we want to send toport
the port of the connection
Returns:
true if successfully sent
Protected Attributes Documentation
variable m_ip
std::optional<IpAddress> m_ip;
variable m_port
unsigned short m_port;
variable m_socket
UdpSocket m_socket;
The documentation for this class was generated from the following file source/Interfaces/NetWorth/NetworkInterface.hpp