Ult3D
Implementation of "Ultimate 3D Game Engine Design & Architecture" by Allan Sherrod
Loading...
Searching...
No Matches
Ult::Network Class Reference

#include <Network.h>

Public Member Functions

 Network (int maxConnections)
 
 ~Network ()
 
bool Host (int port, int numPending)
 
NetResult Connect (const char *ipAddr, int port)
 
void Disconnect ()
 
void DisconnectClient (int index)
 
NetResult Send (Packet &packet)
 
NetResult Send (Packet &packet, int sendTo)
 
void Process ()
 
void SetCallbackFunction (NetCallback funcPtr)
 
bool IsConnected () const
 
int GetMaxConnections () const
 
int GetTotalConnections () const
 
NetType GetNetworkType () const
 

Detailed Description

Wrapper for a network connection, either as a server or client.

Constructor & Destructor Documentation

◆ Network()

Ult::Network::Network ( int maxConnections)

Network constructor.

Parameters
maxConnectionsThe number of maximum connected clients, if this will be a server.

◆ ~Network()

Ult::Network::~Network ( )

Network destructor.

Member Function Documentation

◆ Connect()

NetResult Ult::Network::Connect ( const char * ipAddr,
int port )

Attempt to initialize as a client, connecting to the server at the given ip address and port number.

◆ Disconnect()

void Ult::Network::Disconnect ( )

If a client, disconnect from the server. If a server, close the server. Sends a disconnect message packet to any connections.

◆ DisconnectClient()

void Ult::Network::DisconnectClient ( int index)

If a server, send a disconnect message packet to the client and close the connection to the client at the given index.

◆ GetMaxConnections()

int Ult::Network::GetMaxConnections ( ) const
inline

For servers, returns the maximum allowed number of connections.

◆ GetNetworkType()

NetType Ult::Network::GetNetworkType ( ) const
inline

Returns whether this is a server, client, or uninitialized.

◆ GetTotalConnections()

int Ult::Network::GetTotalConnections ( ) const
inline

For servers, returns the total number of current connections.

◆ Host()

bool Ult::Network::Host ( int port,
int numPending )

Initialize as a server, listening on the given port.

Parameters
numPendingThe maximum queue length of pending connections.
Returns
True on success, false on failure.

◆ IsConnected()

bool Ult::Network::IsConnected ( ) const
inline

Returns whether the network connection is active or not.

◆ Process()

void Ult::Network::Process ( )

Attempts to process any connections and any received data.

◆ Send() [1/2]

NetResult Ult::Network::Send ( Packet & packet)

Send a message packet to any connections.

◆ Send() [2/2]

NetResult Ult::Network::Send ( Packet & packet,
int sendTo )

If a server, send a message packet to a specific client connection.

◆ SetCallbackFunction()

void Ult::Network::SetCallbackFunction ( NetCallback funcPtr)
inline

Sets the function to be called on accepted connection, received data, network errors.


The documentation for this class was generated from the following files: