From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/classNLNET_1_1CBufServer.html | 1786 ++++++++++++++++++++++++ 1 file changed, 1786 insertions(+) create mode 100644 docs/doxygen/nel/classNLNET_1_1CBufServer.html (limited to 'docs/doxygen/nel/classNLNET_1_1CBufServer.html') diff --git a/docs/doxygen/nel/classNLNET_1_1CBufServer.html b/docs/doxygen/nel/classNLNET_1_1CBufServer.html new file mode 100644 index 00000000..1973bea4 --- /dev/null +++ b/docs/doxygen/nel/classNLNET_1_1CBufServer.html @@ -0,0 +1,1786 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# Home   # nevrax.com   
+ + + + +
Nevrax
+ + + + + + + + + + +
+ + +
+ Nevrax.org
+ + + + + + + +
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
+
+ + +
+ + +
+Docs + +
+  + + + + + +
Documentation 
+ +
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  
+

NLNET::CBufServer Class Reference

Server class for layer 1. +More... +

+#include <buf_server.h> +

+

Inheritance diagram for NLNET::CBufServer: +

+ +NLNET::CBufNetBase +NLNET::CCallbackServer + +List of all members. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Types

enum  TThreadStategy { SpreadSockets, +FillThreads + }

Public Methods

 CBufServer (TThreadStategy strategy=DEFAULT_STRATEGY, uint16 max_threads=DEFAULT_MAX_THREADS, uint16 max_sockets_per_thread=DEFAULT_MAX_SOCKETS_PER_THREADS, bool nodelay=true, bool replaymode=false)
 Constructor Set nodelay to true to disable the Nagle buffering algorithm (see CTcpSock documentation). More...

virtual ~CBufServer ()
 Destructor. More...

void init (uint16 port)
 Listens on the specified port. More...

void disconnect (TSockId hostid, bool quick=false)
 Disconnect a connection Set hostid to InvalidSockId to disconnect all connections. More...

void setConnectionCallback (TNetCallback cb, void *arg)
 Sets callback for incoming connections (or NULL to disable callback). More...

void send (const NLMISC::CMemStream &buffer, TSockId hostid)
 Send a message to the specified host, or to all hosts if hostid is InvalidSockId. More...

bool dataAvailable ()
 Checks if there is some data to receive. More...

void receive (NLMISC::CMemStream &buffer, TSockId *hostid)
 Receives next block of data in the specified (resizes the vector) You must call dataAvailable() before every call to receive(). More...

void update ()
 Update the network (call this method evenly). More...

uint32 getSendQueueSize (TSockId destid)
void setTimeFlushTrigger (TSockId destid, sint32 ms)
 Sets the time flush trigger (in millisecond). More...

void setSizeFlushTrigger (TSockId destid, sint32 size)
 Sets the size flush trigger. More...

bool flush (TSockId destid)
 Force to send all data pending in the send queue. More...

const CInetAddresslistenAddress () const
 Returns the internet address of the listening socket. More...

const CInetAddresshostAddress (TSockId hostid)
 Returns the address of the specified host. More...

uint64 bytesReceived () const
 Returns the number of bytes popped by receive() since the beginning. More...

uint64 newBytesReceived ()
 Returns the number of bytes popped by receive() since the previous call to this method. More...

uint64 bytesSent () const
 Returns the number of bytes pushed by send() since the beginning. More...

uint64 newBytesSent ()
 Returns the number of bytes pushed by send() since the previous call to this method. More...

uint32 nbConnections () const
 Returns the number of connections (at the last update()). More...


Protected Methods

bool noDelay () const
 Returns the TCP_NODELAY flag. More...

void dispatchNewSocket (CServerBufSock *bufsock)
 Binds a new socket and send buffer to an existing or a new thread (that starts) Note: this method is called in the listening thread. More...

CServerReceiveTaskreceiveTask (std::vector< NLMISC::IThread * >::iterator ipt)
 Returns the receive task corresponding to a particular thread. More...

void pushBufferToHost (const NLMISC::CMemStream &buffer, TSockId hostid)
 Pushes a buffer to the specified host's send queue and update (unless not connected). More...

void addNewThread (CThreadPool &threadpool, CServerBufSock *bufsock)
TNetCallback connectionCallback () const
 Returns the connection callback. More...

void * argOfConnectionCallback () const
 Returns the argument of the connection callback. More...


Private Attributes

bool _NoDelay
 TCP_NODELAY. More...

TThreadStategy _ThreadStrategy
 Thread socket-handling strategy. More...

uint16 _MaxThreads
 Max number of threads. More...

uint16 _MaxSocketsPerThread
 Max number of sockets handled by one thread. More...

CListenTask_ListenTask
 Listen task. More...

NLMISC::IThread_ListenThread
 Listen thread. More...

NLMISC::CSynchronized< CThreadPool_ThreadPool
TNetCallback _ConnectionCallback
 Connection callback. More...

void * _ConnectionCbArg
 Argument of the connection callback. More...

uint64 _BytesPushedOut
 Number of bytes pushed by send() since the beginning. More...

uint64 _BytesPoppedIn
 Number of bytes popped by receive() since the beginning. More...

uint64 _PrevBytesPoppedIn
 Previous number of bytes received. More...

uint64 _PrevBytesPushedOut
 Previous number of bytes sent. More...

uint32 _NbConnections
 Number of connections (debug stat). More...

bool _ReplayMode
 Replay mode flag. More...


Friends

class CServerBufSock
class CListenTask
class CServerReceiveTask
+

Detailed Description

+Server class for layer 1. +

+Listening socket and accepted connetions, with packet scheme. The provided buffers are sent raw (no endianness conversion). By default, the size time trigger is disabled, the time trigger is set to 20 ms. +

+Where do the methods take place: \begincode send(), -> send buffer -> update(), flush() bytesSent(), newBytesSent() +

+receive(), dataAvailable(), <- receive buffer <- receive thread, dataAvailable(), bytesReceived(), newBytesReceived(), connection callback, disconnection callback +

+

+Author:
+Olivier Cado , Nevrax France
+Date:
+2001
+

+ +

+Definition at line 153 of file buf_server.h.


Member Enumeration Documentation

+

+ + + + +
+ + +
enum NLNET::CBufServer::TThreadStategy +
+
+ + + + + +
+   + + +

+

+Enumeration values:
+ + + +
SpreadSockets  +
FillThreads  +
+
+ +

+Definition at line 157 of file buf_server.h.

+


Constructor & Destructor Documentation

+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NLNET::CBufServer::CBufServer TThreadStategy   strategy = DEFAULT_STRATEGY,
uint16   max_threads = DEFAULT_MAX_THREADS,
uint16   max_sockets_per_thread = DEFAULT_MAX_SOCKETS_PER_THREADS,
bool   nodelay = true,
bool   replaymode = false
+
+ + + + + +
+   + + +

+Constructor Set nodelay to true to disable the Nagle buffering algorithm (see CTcpSock documentation). +

+ +

+Definition at line 57 of file buf_server.cpp. +

+References _ListenTask, _ListenThread, _ReplayMode, CListenTask, and nlnettrace.

+

+ + + + +
+ + + + + + + + + +
NLNET::CBufServer::~CBufServer   [virtual]
+
+ + + + + +
+   + + +

+Destructor. +

+ +

+Definition at line 164 of file buf_server.cpp. +

+References _ListenTask, _ListenThread, _ReplayMode, _ThreadPool, CListenTask, CServerReceiveTask, NLMISC::IThread::getRunnable, nldebug, nlnettrace, receiveTask, and NLMISC::IThread::wait.

+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NLNET::CBufServer::addNewThread CThreadPool  threadpool,
CServerBufSock  bufsock
[protected]
+
+ + + + + +
+   + + +

+ +

+Definition at line 910 of file buf_server.cpp. +

+References CServerReceiveTask, NLNET::CThreadPool, nlassert, nldebug, and nlnettrace. +

+Referenced by dispatchNewSocket.

+

+ + + + +
+ + + + + + + + + +
void* NLNET::CBufServer::argOfConnectionCallback   const [inline, protected]
+
+ + + + + +
+   + + +

+Returns the argument of the connection callback. +

+ +

+Definition at line 306 of file buf_server.h. +

+References _ConnectionCbArg. +

+Referenced by dataAvailable.

+

+ + + + +
+ + + + + + + + + +
uint64 NLNET::CBufServer::bytesReceived   const [inline]
+
+ + + + + +
+   + + +

+Returns the number of bytes popped by receive() since the beginning. +

+ +

+Definition at line 247 of file buf_server.h. +

+References _BytesPoppedIn. +

+Referenced by newBytesReceived.

+

+ + + + +
+ + + + + + + + + +
uint64 NLNET::CBufServer::bytesSent   const [inline]
+
+ + + + + +
+   + + +

+Returns the number of bytes pushed by send() since the beginning. +

+ +

+Definition at line 253 of file buf_server.h. +

+References _BytesPushedOut. +

+Referenced by newBytesSent.

+

+ + + + +
+ + + + + + + + + +
TNetCallback NLNET::CBufServer::connectionCallback   const [inline, protected]
+
+ + + + + +
+   + + +

+Returns the connection callback. +

+ +

+Definition at line 303 of file buf_server.h. +

+References _ConnectionCallback, and NLNET::TNetCallback. +

+Referenced by dataAvailable.

+

+ + + + +
+ + + + + + + + + +
bool NLNET::CBufServer::dataAvailable  
+
+ + + + + +
+   + + +

+Checks if there is some data to receive. +

+Returns false if the receive queue is empty. This is where the connection/disconnection callbacks can be called. +

+Reimplemented in NLNET::CCallbackServer. +

+Definition at line 374 of file buf_server.cpp. +

+References argOfConnectionCallback, NLNET::CBufNetBase::argOfDisconnectionCallback, NLNET::CFifoAccessor, connectionCallback, CServerBufSock, NLNET::CBufNetBase::dataAvailableFlag, NLNET::CBufNetBase::disconnectionCallback, nlassert, nldebug, nlerror, nlinfo, NLNET::CBufNetBase::receiveQueue, NLNET::CBufNetBase::setDataAvailableFlag, and NLNET::TSockId.

+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NLNET::CBufServer::disconnect TSockId   hostid,
bool   quick = false
+
+ + + + + +
+   + + +

+Disconnect a connection Set hostid to InvalidSockId to disconnect all connections. +

+If hostid is not InvalidSockId and the socket is not connected, the method does nothing. If quick is true, any pending data will not be sent before disconnecting. +

+Definition at line 261 of file buf_server.cpp. +

+References _ThreadPool, CServerReceiveTask, nlnettrace, receiveTask, and NLNET::TSockId.

+

+ + + + +
+ + + + + + + + + + +
void NLNET::CBufServer::dispatchNewSocket CServerBufSock  bufsock [protected]
+
+ + + + + +
+   + + +

+Binds a new socket and send buffer to an existing or a new thread (that starts) Note: this method is called in the listening thread. +

+ +

+Definition at line 818 of file buf_server.cpp. +

+References _MaxSocketsPerThread, _MaxThreads, _ThreadPool, _ThreadStrategy, addNewThread, CServerReceiveTask, min, nldebug, nlnettrace, nlwarning, receiveTask, and SpreadSockets.

+

+ + + + +
+ + + + + + + + + + +
bool NLNET::CBufServer::flush TSockId   destid [inline]
+
+ + + + + +
+   + + +

+Force to send all data pending in the send queue. +

+

+Returns:
+False if an error has occured (e.g. the remote host is disconnected). To retrieve the reason of the error, call CSock::getLastError() and/or CSock::errorString()
+

+Reimplemented in NLNET::CCallbackServer. +

+Definition at line 224 of file buf_server.h. +

+References nlassert, and NLNET::TSockId.

+

+ + + + +
+ + + + + + + + + + +
uint32 NLNET::CBufServer::getSendQueueSize TSockId   destid
+
+ + + + + +
+   + + +

+ +

+Definition at line 670 of file buf_server.cpp. +

+References _ThreadPool, CServerReceiveTask, receiveTask, and NLNET::TSockId.

+

+ + + + +
+ + + + + + + + + + +
const CInetAddress& NLNET::CBufServer::hostAddress TSockId   hostid [inline]
+
+ + + + + +
+   + + +

+Returns the address of the specified host. +

+ +

+Reimplemented in NLNET::CCallbackServer. +

+Definition at line 233 of file buf_server.h. +

+References nlassert, and NLNET::TSockId.

+

+ + + + +
+ + + + + + + + + + +
void NLNET::CBufServer::init uint16   port
+
+ + + + + +
+   + + +

+Listens on the specified port. +

+ +

+Definition at line 92 of file buf_server.cpp. +

+References _ListenTask, _ListenThread, _ReplayMode, nldebug, nlnettrace, and NLMISC::IThread::start.

+

+ + + + +
+ + + + + + + + + +
const CInetAddress& NLNET::CBufServer::listenAddress   const [inline]
+
+ + + + + +
+   + + +

+Returns the internet address of the listening socket. +

+ +

+Definition at line 230 of file buf_server.h. +

+References _ListenTask.

+

+ + + + +
+ + + + + + + + + +
uint32 NLNET::CBufServer::nbConnections   const [inline]
+
+ + + + + +
+   + + +

+Returns the number of connections (at the last update()). +

+ +

+Definition at line 259 of file buf_server.h. +

+References _NbConnections. +

+Referenced by NLNET::CCallbackServer::send.

+

+ + + + +
+ + + + + + + + + +
uint64 NLNET::CBufServer::newBytesReceived  
+
+ + + + + +
+   + + +

+Returns the number of bytes popped by receive() since the previous call to this method. +

+ +

+Definition at line 709 of file buf_server.cpp. +

+References _PrevBytesPoppedIn, and bytesReceived.

+

+ + + + +
+ + + + + + + + + +
uint64 NLNET::CBufServer::newBytesSent  
+
+ + + + + +
+   + + +

+Returns the number of bytes pushed by send() since the previous call to this method. +

+ +

+Definition at line 721 of file buf_server.cpp. +

+References _PrevBytesPushedOut, and bytesSent.

+

+ + + + +
+ + + + + + + + + +
bool NLNET::CBufServer::noDelay   const [inline, protected]
+
+ + + + + +
+   + + +

+Returns the TCP_NODELAY flag. +

+ +

+Definition at line 268 of file buf_server.h. +

+References _NoDelay.

+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NLNET::CBufServer::pushBufferToHost const NLMISC::CMemStream  buffer,
TSockId   hostid
[inline, protected]
+
+ + + + + +
+   + + +

+Pushes a buffer to the specified host's send queue and update (unless not connected). +

+ +

+Definition at line 290 of file buf_server.h. +

+References _BytesPushedOut, NLMISC::CMemStream::length, nlassert, and NLNET::TSockId.

+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NLNET::CBufServer::receive NLMISC::CMemStream  buffer,
TSockId  hostid
+
+ + + + + +
+   + + +

+Receives next block of data in the specified (resizes the vector) You must call dataAvailable() before every call to receive(). +

+ +

+Definition at line 575 of file buf_server.cpp. +

+References _BytesPoppedIn, NLNET::CFifoAccessor, nlassert, NLMISC_BSWAP32, nlnettrace, nlwarning, NLNET::CBufNetBase::receiveQueue, NLNET::CBufNetBase::setDataAvailableFlag, and NLNET::TSockId.

+

+ + + + +
+ + + + + + + + + + +
CServerReceiveTask* NLNET::CBufServer::receiveTask std::vector< NLMISC::IThread * >::iterator   ipt [inline, protected]
+
+ + + + + +
+   + + +

+Returns the receive task corresponding to a particular thread. +

+ +

+Definition at line 276 of file buf_server.h. +

+References CServerReceiveTask. +

+Referenced by disconnect, dispatchNewSocket, getSendQueueSize, update, and ~CBufServer.

+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NLNET::CBufServer::send const NLMISC::CMemStream  buffer,
TSockId   hostid
+
+ + + + + +
+   + + +

+Send a message to the specified host, or to all hosts if hostid is InvalidSockId. +

+ +

+Reimplemented in NLNET::CCallbackServer.

+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NLNET::CBufServer::setConnectionCallback TNetCallback   cb,
void *   arg
[inline]
+
+ + + + + +
+   + + +

+Sets callback for incoming connections (or NULL to disable callback). +

+ +

+Reimplemented in NLNET::CCallbackServer. +

+Definition at line 181 of file buf_server.h. +

+References _ConnectionCallback, _ConnectionCbArg, and NLNET::TNetCallback.

+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NLNET::CBufServer::setSizeFlushTrigger TSockId   destid,
sint32   size
[inline]
+
+ + + + + +
+   + + +

+Sets the size flush trigger. +

+When the size of the send queue reaches or exceeds this calue, all data in the send queue is automatically sent (-1 to disable this trigger ) +

+Definition at line 218 of file buf_server.h. +

+References nlassert, and NLNET::TSockId.

+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NLNET::CBufServer::setTimeFlushTrigger TSockId   destid,
sint32   ms
[inline]
+
+ + + + + +
+   + + +

+Sets the time flush trigger (in millisecond). +

+When this time is elapsed, all data in the send queue is automatically sent (-1 to disable this trigger) +

+Definition at line 213 of file buf_server.h. +

+References nlassert, and NLNET::TSockId.

+

+ + + + +
+ + + + + + + + + +
void NLNET::CBufServer::update  
+
+ + + + + +
+   + + +

+Update the network (call this method evenly). +

+ +

+Definition at line 623 of file buf_server.cpp. +

+References _NbConnections, _ThreadPool, CServerReceiveTask, nldebug, and receiveTask.

+


Friends And Related Function Documentation

+

+ + + + +
+ + +
friend class CListenTask [friend] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 264 of file buf_server.h. +

+Referenced by CBufServer, and ~CBufServer.

+

+ + + + +
+ + +
friend class CServerBufSock [friend] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 263 of file buf_server.h. +

+Referenced by dataAvailable.

+

+ + + + +
+ + +
friend class CServerReceiveTask [friend] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 265 of file buf_server.h. +

+Referenced by addNewThread, disconnect, dispatchNewSocket, getSendQueueSize, receiveTask, update, and ~CBufServer.

+


Member Data Documentation

+

+ + + + +
+ + +
uint64 NLNET::CBufServer::_BytesPoppedIn [private] +
+
+ + + + + +
+   + + +

+Number of bytes popped by receive() since the beginning. +

+ +

+Definition at line 350 of file buf_server.h. +

+Referenced by bytesReceived, and receive.

+

+ + + + +
+ + +
uint64 NLNET::CBufServer::_BytesPushedOut [private] +
+
+ + + + + +
+   + + +

+Number of bytes pushed by send() since the beginning. +

+ +

+Definition at line 347 of file buf_server.h. +

+Referenced by bytesSent, and pushBufferToHost.

+

+ + + + +
+ + +
TNetCallback NLNET::CBufServer::_ConnectionCallback [private] +
+
+ + + + + +
+   + + +

+Connection callback. +

+ +

+Reimplemented in NLNET::CCallbackServer. +

+Definition at line 341 of file buf_server.h. +

+Referenced by connectionCallback, and setConnectionCallback.

+

+ + + + +
+ + +
void* NLNET::CBufServer::_ConnectionCbArg [private] +
+
+ + + + + +
+   + + +

+Argument of the connection callback. +

+ +

+Reimplemented in NLNET::CCallbackServer. +

+Definition at line 344 of file buf_server.h. +

+Referenced by argOfConnectionCallback, and setConnectionCallback.

+

+ + + + +
+ + +
CListenTask* NLNET::CBufServer::_ListenTask [private] +
+
+ + + + + +
+   + + +

+Listen task. +

+ +

+Definition at line 327 of file buf_server.h. +

+Referenced by CBufServer, init, listenAddress, and ~CBufServer.

+

+ + + + +
+ + +
NLMISC::IThread* NLNET::CBufServer::_ListenThread [private] +
+
+ + + + + +
+   + + +

+Listen thread. +

+ +

+Definition at line 330 of file buf_server.h. +

+Referenced by CBufServer, init, and ~CBufServer.

+

+ + + + +
+ + +
uint16 NLNET::CBufServer::_MaxSocketsPerThread [private] +
+
+ + + + + +
+   + + +

+Max number of sockets handled by one thread. +

+ +

+Definition at line 324 of file buf_server.h. +

+Referenced by dispatchNewSocket.

+

+ + + + +
+ + +
uint16 NLNET::CBufServer::_MaxThreads [private] +
+
+ + + + + +
+   + + +

+Max number of threads. +

+ +

+Definition at line 321 of file buf_server.h. +

+Referenced by dispatchNewSocket.

+

+ + + + +
+ + +
uint32 NLNET::CBufServer::_NbConnections [private] +
+
+ + + + + +
+   + + +

+Number of connections (debug stat). +

+ +

+Definition at line 359 of file buf_server.h. +

+Referenced by nbConnections, and update.

+

+ + + + +
+ + +
bool NLNET::CBufServer::_NoDelay [private] +
+
+ + + + + +
+   + + +

+TCP_NODELAY. +

+ +

+Definition at line 315 of file buf_server.h. +

+Referenced by noDelay.

+

+ + + + +
+ + +
uint64 NLNET::CBufServer::_PrevBytesPoppedIn [private] +
+
+ + + + + +
+   + + +

+Previous number of bytes received. +

+ +

+Definition at line 353 of file buf_server.h. +

+Referenced by newBytesReceived.

+

+ + + + +
+ + +
uint64 NLNET::CBufServer::_PrevBytesPushedOut [private] +
+
+ + + + + +
+   + + +

+Previous number of bytes sent. +

+ +

+Definition at line 356 of file buf_server.h. +

+Referenced by newBytesSent.

+

+ + + + +
+ + +
bool NLNET::CBufServer::_ReplayMode [private] +
+
+ + + + + +
+   + + +

+Replay mode flag. +

+ +

+Definition at line 362 of file buf_server.h. +

+Referenced by CBufServer, init, and ~CBufServer.

+

+ + + + +
+ + +
NLMISC::CSynchronized<CThreadPool> NLNET::CBufServer::_ThreadPool [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 338 of file buf_server.h. +

+Referenced by disconnect, dispatchNewSocket, getSendQueueSize, update, and ~CBufServer.

+

+ + + + +
+ + +
TThreadStategy NLNET::CBufServer::_ThreadStrategy [private] +
+
+ + + + + +
+   + + +

+Thread socket-handling strategy. +

+ +

+Definition at line 318 of file buf_server.h. +

+Referenced by dispatchNewSocket.

+


The documentation for this class was generated from the following files: + + + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1