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

#include <Socket.h>

Public Member Functions

 Socket ()
 
 ~Socket ()
 
bool SetAsServer (int port, int numPending)
 
bool ConnectToServer (const char *ipAddr, int port)
 
bool AcceptConnection (Socket &client)
 
NetResult SendData (Packet &packet)
 
NetResult ReceiveData (Packet &packet, int *bytesRead)
 
void Disconnect ()
 
bool IsConnected () const
 
bool operator== (const Socket &rhs)
 
void operator= (const Socket &rhs)
 
ULT_SOCKET GetSocket () const
 

Detailed Description

Wraps a system network socket instance.

Constructor & Destructor Documentation

◆ Socket()

Ult::Socket::Socket ( )

Socket constructor.

◆ ~Socket()

Ult::Socket::~Socket ( )

Socket destructor.

Member Function Documentation

◆ AcceptConnection()

bool Ult::Socket::AcceptConnection ( Socket & client)

As a server, attempt to accept a connection from the given client socket, initializing it.

Returns
True on success, false on failure.

◆ ConnectToServer()

bool Ult::Socket::ConnectToServer ( const char * ipAddr,
int port )

Initialize the socket as a client to a server at the given IP address and port number.

Returns
True on success, false on failure.

◆ Disconnect()

void Ult::Socket::Disconnect ( )

Close this socket.

◆ GetSocket()

ULT_SOCKET Ult::Socket::GetSocket ( ) const
inline

Get the underlying system socket.

◆ IsConnected()

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

Return whether this socket has been initialized or not.

◆ operator=()

void Ult::Socket::operator= ( const Socket & rhs)
inline

Set this socket equal to the input socket.

◆ operator==()

bool Ult::Socket::operator== ( const Socket & rhs)
inline

Check if this and the input socket are equal.

◆ ReceiveData()

NetResult Ult::Socket::ReceiveData ( Packet & packet,
int * bytesRead )

Attempt to receive data (nonblocking) on this socket into packet, storing the number of bytes received in bytesRead.

◆ SendData()

NetResult Ult::Socket::SendData ( Packet & packet)

Send the given packet over the network via this socket.

◆ SetAsServer()

bool Ult::Socket::SetAsServer ( int port,
int numPending )

Initialize the socket as a server on the given port number, with a maximum pending-connection queue size.

Returns
True on success, false on failure.

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