|
|
|
|
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 ReferenceServer class for layer 1.
More...
#include <buf_server.h>
Inheritance diagram for NLNET::CBufServer:
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 CInetAddress & | listenAddress () const |
| Returns the internet address of the listening socket. More...
|
const CInetAddress & | hostAddress (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...
|
CServerReceiveTask * | receiveTask (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 |
|
) |
|
|
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::argOfConnectionCallback |
( |
|
) |
const [inline, protected] |
|
uint64 NLNET::CBufServer::bytesReceived |
( |
|
) |
const [inline] |
|
uint64 NLNET::CBufServer::bytesSent |
( |
|
) |
const [inline] |
|
TNetCallback NLNET::CBufServer::connectionCallback |
( |
|
) |
const [inline, protected] |
|
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 |
|
) |
|
|
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] |
|
void NLNET::CBufServer::init |
( |
uint16 |
port |
) |
|
|
const CInetAddress& NLNET::CBufServer::listenAddress |
( |
|
) |
const [inline] |
|
uint32 NLNET::CBufServer::nbConnections |
( |
|
) |
const [inline] |
|
uint64 NLNET::CBufServer::newBytesReceived |
( |
|
) |
|
|
uint64 NLNET::CBufServer::newBytesSent |
( |
|
) |
|
|
bool NLNET::CBufServer::noDelay |
( |
|
) |
const [inline, protected] |
|
|
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] |
|
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 |
( |
|
) |
|
|
Friends And Related Function Documentation
friend class CListenTask [friend]
|
|
friend class CServerBufSock [friend]
|
|
friend class CServerReceiveTask [friend]
|
|
Member Data Documentation
uint64 NLNET::CBufServer::_BytesPoppedIn [private]
|
|
uint64 NLNET::CBufServer::_BytesPushedOut [private]
|
|
TNetCallback NLNET::CBufServer::_ConnectionCallback [private]
|
|
void* NLNET::CBufServer::_ConnectionCbArg [private]
|
|
uint16 NLNET::CBufServer::_MaxSocketsPerThread [private]
|
|
uint16 NLNET::CBufServer::_MaxThreads [private]
|
|
uint32 NLNET::CBufServer::_NbConnections [private]
|
|
bool NLNET::CBufServer::_NoDelay [private]
|
|
uint64 NLNET::CBufServer::_PrevBytesPoppedIn [private]
|
|
uint64 NLNET::CBufServer::_PrevBytesPushedOut [private]
|
|
bool NLNET::CBufServer::_ReplayMode [private]
|
|
NLMISC::CSynchronized<CThreadPool> NLNET::CBufServer::_ThreadPool [private]
|
|
The documentation for this class was generated from the following files:
|
|