Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
Nz::AbstractSocket Class Reference

Network class that represents the base of socket. More...

Inheritance diagram for Nz::AbstractSocket:
Nz::TcpClient Nz::TcpServer Nz::UdpSocket

Public Member Functions

 AbstractSocket (const AbstractSocket &)=delete
 
 AbstractSocket (AbstractSocket &&abstractSocket)
 Constructs a AbstractSocket object with another one by move semantic. More...
 
virtual ~AbstractSocket ()
 Destructs the object and calls Close. More...
 
void Close ()
 Closes the socket.
 
void EnableBlocking (bool blocking)
 Enables blocking. More...
 
SocketError GetLastError () const
 Gets the last error. More...
 
SocketHandle GetNativeHandle () const
 Gets the internal socket handle. More...
 
SocketState GetState () const
 Gets the internal state. More...
 
SocketType GetType () const
 Gets the internal type. More...
 
bool IsBlockingEnabled () const
 Checks whether the blocking is enabled. More...
 
std::size_t QueryAvailableBytes () const
 Queries the available bytes. More...
 
std::size_t QueryReceiveBufferSize () const
 Queries the maximum socket receive buffer size. More...
 
std::size_t QuerySendBufferSize () const
 Queries the maximum socket send buffer size. More...
 
void SetReceiveBufferSize (std::size_t size)
 Sets the maximum receive buffer size. More...
 
void SetSendBufferSize (std::size_t size)
 Sets the maximum send buffer size. More...
 
AbstractSocketoperator= (const AbstractSocket &)=delete
 
AbstractSocketoperator= (AbstractSocket &&abstractSocket)
 Moves the AbstractSocket into this. More...
 
 NazaraSignal (OnStateChange, const AbstractSocket *, SocketState)
 

Protected Member Functions

 AbstractSocket (SocketType type)
 Constructs a AbstractSocket object with a type.
 
virtual void OnClose ()
 Operation to do when closing socket.
 
virtual void OnOpened ()
 Operation to do when opening socket. More...
 
bool Open (NetProtocol protocol)
 Opens the socket according to a net protocol. More...
 
void Open (SocketHandle existingHandle)
 Opens the socket according to a socket handle. More...
 
void UpdateState (SocketState newState)
 Updates the state of the socket. More...
 

Protected Attributes

NetProtocol m_protocol
 
SocketError m_lastError
 
SocketHandle m_handle
 
SocketState m_state
 
SocketType m_type
 
bool m_isBlockingEnabled
 

Detailed Description

Network class that represents the base of socket.

Remarks
This class is abstract

Constructor & Destructor Documentation

◆ AbstractSocket()

Nz::AbstractSocket::AbstractSocket ( AbstractSocket &&  abstractSocket)

Constructs a AbstractSocket object with another one by move semantic.

Parameters
abstractSocketAbstractSocket to move into this

◆ ~AbstractSocket()

Nz::AbstractSocket::~AbstractSocket ( )
virtual

Destructs the object and calls Close.

See also
Close

Member Function Documentation

◆ EnableBlocking()

void Nz::AbstractSocket::EnableBlocking ( bool  blocking)

Enables blocking.

Parameters
blockingShould the read block

◆ GetLastError()

SocketError Nz::AbstractSocket::GetLastError ( ) const
inline

Gets the last error.

Returns
Socket error

◆ GetNativeHandle()

SocketHandle Nz::AbstractSocket::GetNativeHandle ( ) const
inline

Gets the internal socket handle.

Returns
Socket handle

◆ GetState()

SocketState Nz::AbstractSocket::GetState ( ) const
inline

Gets the internal state.

Returns
Socket state

◆ GetType()

SocketType Nz::AbstractSocket::GetType ( ) const
inline

Gets the internal type.

Returns
Socket type

◆ IsBlockingEnabled()

bool Nz::AbstractSocket::IsBlockingEnabled ( ) const
inline

Checks whether the blocking is enabled.

Returns
true If successful

◆ OnOpened()

void Nz::AbstractSocket::OnOpened ( )
protectedvirtual

Operation to do when opening socket.

Remarks
Produces a NazaraWarning if blocking failed

◆ Open() [1/2]

bool Nz::AbstractSocket::Open ( NetProtocol  protocol)
protected

Opens the socket according to a net protocol.

Returns
true If successful

◆ Open() [2/2]

void Nz::AbstractSocket::Open ( SocketHandle  handle)
protected

Opens the socket according to a socket handle.

Returns
true If successful
Remarks
Produces a NazaraAssert if handle is invalid

◆ operator=()

AbstractSocket & Nz::AbstractSocket::operator= ( AbstractSocket &&  abstractSocket)

Moves the AbstractSocket into this.

Returns
A reference to this
Parameters
abstractSocketAbstractSocket to move in this

◆ QueryAvailableBytes()

std::size_t Nz::AbstractSocket::QueryAvailableBytes ( ) const

Queries the available bytes.

Returns
Number of bytes which can be read

◆ QueryReceiveBufferSize()

std::size_t Nz::AbstractSocket::QueryReceiveBufferSize ( ) const

Queries the maximum socket receive buffer size.

Returns
The size of the receive buffer in bytes.

◆ QuerySendBufferSize()

std::size_t Nz::AbstractSocket::QuerySendBufferSize ( ) const

Queries the maximum socket send buffer size.

Returns
The size of the send buffer in bytes.

◆ SetReceiveBufferSize()

void Nz::AbstractSocket::SetReceiveBufferSize ( std::size_t  size)

Sets the maximum receive buffer size.

Parameters
sizeThe new maximum receive buffer size in bytes

◆ SetSendBufferSize()

void Nz::AbstractSocket::SetSendBufferSize ( std::size_t  size)

Sets the maximum send buffer size.

Parameters
sizeThe new maximum send buffer size in bytes

◆ UpdateState()

void Nz::AbstractSocket::UpdateState ( SocketState  newState)
inlineprotected

Updates the state of the socket.

Parameters
newStateNext state for the socket

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