Nebula
Loading...
Searching...
No Matches
Net::StdTcpServer Class Reference

#include <stdtcpserver.h>

Detailed Description

A TcpServer opens a socket and listens for connecting TcpClients.

This listen process happens in its own listener-thread and thus doesn't block the application. Each connected client is represented through a TcpClientConnection object which can be used by the application to communicate with a specific client.

Inherits Core::RefCounted.

Classes

class  ListenerThread
 a private listener thread class More...
 

Public Member Functions

 StdTcpServer ()
 constructor
 
virtual ~StdTcpServer ()
 destructor
 
void SetAddress (const IpAddress &addr)
 set address, hostname can be "any", "self" or "inetself"
 
const IpAddressGetAddress () const
 get address
 
void SetClientConnectionClass (const Core::Rtti &type)
 set client connection class
 
const Core::RttiGetClientConnectionClass ()
 get client connection class
 
bool Open ()
 open the server
 
void Close ()
 close the server
 
bool IsOpen () const
 return true if server is open
 
Util::Array< Ptr< TcpClientConnection > > Recv ()
 poll clients connections for received data, call this frequently!
 
bool Broadcast (const Ptr< IO::Stream > &msg)
 broadcast a message to all clients
 
- Public Member Functions inherited from Core::RefCounted
 RefCounted ()
 constructor
 
int GetRefCount () const
 get the current refcount
 
void AddRef ()
 increment refcount by one
 
void Release ()
 decrement refcount and destroy object if refcount is zero
 
bool IsInstanceOf (const Rtti &rtti) const
 return true if this object is instance of given class
 
bool IsInstanceOf (const Util::String &className) const
 return true if this object is instance of given class by string
 
bool IsInstanceOf (const Util::FourCC &classFourCC) const
 return true if this object is instance of given class by fourcc
 
bool IsA (const Rtti &rtti) const
 return true if this object is instance of given class, or a derived class
 
bool IsA (const Util::String &rttiName) const
 return true if this object is instance of given class, or a derived class, by string
 
bool IsA (const Util::FourCC &rttiFourCC) const
 return true if this object is instance of given class, or a derived class, by fourcc
 
const Util::StringGetClassName () const
 get the class name
 
Util::FourCC GetClassFourCC () const
 get the class FourCC code
 

Private Member Functions

 __DeclareClass (StdTcpServer)
 
void AddClientConnection (const Ptr< TcpClientConnection > &connection)
 add a client connection (called by the listener thread)
 

Private Attributes

IpAddress ipAddress
 
Ptr< ListenerThreadlistenerThread
 
bool isOpen
 
Util::Array< Ptr< TcpClientConnection > > clientConnections
 
Threading::CriticalSection connectionCritSect
 
const Core::RtticonnectionClassRtti
 

Friends

class ListenerThread
 

Additional Inherited Members

- Static Public Member Functions inherited from Core::RefCounted
static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA_DEBUG builds only!)
 
- Protected Member Functions inherited from Core::RefCounted
virtual ~RefCounted ()
 destructor (called when refcount reaches zero)
 

Constructor & Destructor Documentation

◆ StdTcpServer()

Net::StdTcpServer::StdTcpServer ( )

constructor

◆ ~StdTcpServer()

Net::StdTcpServer::~StdTcpServer ( )
virtual

destructor

Member Function Documentation

◆ __DeclareClass()

Net::StdTcpServer::__DeclareClass ( StdTcpServer )
private

◆ AddClientConnection()

void Net::StdTcpServer::AddClientConnection ( const Ptr< TcpClientConnection > & connection)
private

add a client connection (called by the listener thread)

◆ Broadcast()

bool Net::StdTcpServer::Broadcast ( const Ptr< IO::Stream > & msg)

broadcast a message to all clients

◆ Close()

void Net::StdTcpServer::Close ( )

close the server

◆ GetAddress()

const IpAddress & Net::StdTcpServer::GetAddress ( ) const
inline

get address

◆ GetClientConnectionClass()

const Core::Rtti & Net::StdTcpServer::GetClientConnectionClass ( )
inline

get client connection class

◆ IsOpen()

bool Net::StdTcpServer::IsOpen ( ) const
inline

return true if server is open

◆ Open()

bool Net::StdTcpServer::Open ( )

open the server

◆ Recv()

Array< Ptr< TcpClientConnection > > Net::StdTcpServer::Recv ( )

poll clients connections for received data, call this frequently!

◆ SetAddress()

void Net::StdTcpServer::SetAddress ( const IpAddress & addr)
inline

set address, hostname can be "any", "self" or "inetself"

◆ SetClientConnectionClass()

void Net::StdTcpServer::SetClientConnectionClass ( const Core::Rtti & type)
inline

set client connection class

Friends And Related Symbol Documentation

◆ ListenerThread

friend class ListenerThread
friend

Member Data Documentation

◆ clientConnections

Util::Array<Ptr<TcpClientConnection> > Net::StdTcpServer::clientConnections
private

◆ connectionClassRtti

const Core::Rtti* Net::StdTcpServer::connectionClassRtti
private

◆ connectionCritSect

Threading::CriticalSection Net::StdTcpServer::connectionCritSect
private

◆ ipAddress

IpAddress Net::StdTcpServer::ipAddress
private

◆ isOpen

bool Net::StdTcpServer::isOpen
private

◆ listenerThread

Ptr<ListenerThread> Net::StdTcpServer::listenerThread
private

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