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

Network class that represents a server in a TCP connection. More...

Inheritance diagram for Nz::TcpServer:
Nz::AbstractSocket

Public Member Functions

 TcpServer ()
 Constructs a TcpServer object by default.
 
 TcpServer (TcpServer &&tcpServer)
 Constructs a TcpServer object with another one by move semantic. More...
 
bool AcceptClient (TcpClient *newClient)
 Accepts a client. More...
 
IpAddress GetBoundAddress () const
 Gets the bound address. More...
 
UInt16 GetBoundPort () const
 Gets the port of the bound address. More...
 
SocketState Listen (NetProtocol protocol, UInt16 port, unsigned int queueSize=10)
 Listens to a socket. More...
 
SocketState Listen (const IpAddress &address, unsigned int queueSize=10)
 Listens to a socket. More...
 
- Public Member Functions inherited from Nz::AbstractSocket
 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)
 

Additional Inherited Members

- Protected Member Functions inherited from Nz::AbstractSocket
 AbstractSocket (SocketType type)
 Constructs a AbstractSocket object with a type.
 
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 inherited from Nz::AbstractSocket
NetProtocol m_protocol
 
SocketError m_lastError
 
SocketHandle m_handle
 
SocketState m_state
 
SocketType m_type
 
bool m_isBlockingEnabled
 

Detailed Description

Network class that represents a server in a TCP connection.

Constructor & Destructor Documentation

◆ TcpServer()

Nz::TcpServer::TcpServer ( TcpServer &&  tcpServer)
inline

Constructs a TcpServer object with another one by move semantic.

Parameters
tcpServerTcpServer to move into this

Member Function Documentation

◆ AcceptClient()

bool Nz::TcpServer::AcceptClient ( TcpClient newClient)

Accepts a client.

Returns
true If client'socket is valid
Parameters
newClientClient connection
Remarks
Produces a NazaraAssert if socket is invalid
Produces a NazaraAssert if newClient is invalid

◆ GetBoundAddress()

IpAddress Nz::TcpServer::GetBoundAddress ( ) const
inline

Gets the bound address.

Returns
IpAddress we are linked to

◆ GetBoundPort()

UInt16 Nz::TcpServer::GetBoundPort ( ) const
inline

Gets the port of the bound address.

Returns
Port we are linked to

◆ Listen() [1/2]

SocketState Nz::TcpServer::Listen ( NetProtocol  protocol,
UInt16  port,
unsigned int  queueSize = 10 
)
inline

Listens to a socket.

Returns
State of the socket
Parameters
protocolNet protocol to listen to
portPort to listen to
queueSizeSize of the queue
Remarks
Produces a NazaraAssert if protocol is unknown or any

◆ Listen() [2/2]

SocketState Nz::TcpServer::Listen ( const IpAddress address,
unsigned int  queueSize = 10 
)

Listens to a socket.

Returns
State of the socket
Parameters
addressAddress to listen to
queueSizeSize of the queue
Remarks
Produces a NazaraAssert if address is invalid

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