# 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::CBufSock Class Reference

CBufSock A socket and its sending buffer. More...

#include <buf_sock.h>

Inheritance diagram for NLNET::CBufSock:

NLNET::CServerBufSock List of all members.

Public Methods

virtual ~CBufSock ()
 Destructor. More...

void setAppId (uint64 id)
 Sets the application identifier. More...

uint64 appId () const
 Returns the application identifier. More...

std::string asString () const
 Returns a string with the characteristics of the object. More...


Public Attributes

std::string AuthorizedCallback
 Little tricky but this string is used by Layer4 to know which callback is authorized. This is empty when all callback are authorized. More...

uint32 SendNextValue
uint32 ReceiveNextValue

Protected Methods

 CBufSock (CTcpSock *sock=NULL)
 Constructor. More...

virtual std::string typeStr () const
 Returns "CLT " (client). More...

bool advertiseDisconnection (CBufNetBase *bnb, TSockId sockid)
 Pushes a disconnection message into bnb's receive queue, if it has not already been done (returns true in this case). More...

bool advertiseSystemEvent (CBufNetBase *bnb, TSockId sockid, bool &flag, bool condition, CBufNetBase::TEventType event)
 Pushes a system message into bnb's receive queue, if the flags meets the condition, then resets the flag and returns true. More...

bool pushBuffer (const NLMISC::CMemStream &buffer)
 Pushes a buffer to the send queue and update, or returns false if the socket is not physically connected the or an error occured during sending. More...

void connect (const CInetAddress &addr, bool nodelay, bool connectedstate)
 Connects to the specified addr; set connectedstate to true if no connection advertising is needed. More...

void disconnect (bool connectedstate)
 Disconnects; set connectedstate to false if no disconnection advertising is needed. More...

void setConnectedState (bool connectedstate)
 Sets the "logically connected" state (changed when processing a connection/disconnection callback). More...

bool connectedState () const
 Returns the "logically connected" state (changed when processing a connection/disconnection callback). More...

Sending data
bool update ()
 Update the network sending (call this method evenly). Returns false if an error occured. More...

void setTimeFlushTrigger (sint32 ms)
 Sets the time flush trigger (in millisecond). More...

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

bool flush ()
 Forces to send all data pending in the send queue. More...


Protected Attributes

NLMISC::CBufFIFO SendFifo
CTcpSockSock
bool _KnowConnected

Private Attributes

NLMISC::TTime _LastFlushTime
NLMISC::TTime _TriggerTime
sint32 _TriggerSize
NLMISC::CObjectVector< uint8_ReadyToSendBuffer
TBlockSize _RTSBIndex
uint64 _AppId
bool _ConnectedState

Friends

class CBufClient
class CBufServer
class CClientReceiveTask
class CServerReceiveTask
class CCallbackClient
class CCallbackServer
class CCallbackNetBase

Detailed Description

CBufSock A socket and its sending buffer.

Definition at line 52 of file buf_sock.h.


Constructor & Destructor Documentation

NLNET::CBufSock::~CBufSock   [virtual]
 

Destructor.

Definition at line 81 of file buf_sock.cpp.

References _AppId, _ConnectedState, _KnowConnected, _LastFlushTime, _ReadyToSendBuffer, _RTSBIndex, _TriggerSize, _TriggerTime, AuthorizedCallback, NLMISC::CObjectVector< uint8 >::clear, nlassert, nlnettrace, and Sock.

NLNET::CBufSock::CBufSock CTcpSock   sock = NULL [protected]
 

Constructor.

Definition at line 52 of file buf_sock.cpp.

References _LastFlushTime, nlnettrace, and Sock.


Member Function Documentation

bool NLNET::CBufSock::advertiseDisconnection CBufNetBase   bnb,
TSockId    sockid
[inline, protected]
 

Pushes a disconnection message into bnb's receive queue, if it has not already been done (returns true in this case).

You can either specify a sockid (for server) or InvalidSockId (for client)

Definition at line 120 of file buf_sock.h.

References _KnowConnected, advertiseSystemEvent, nlassert, and NLNET::TSockId.

bool NLNET::CBufSock::advertiseSystemEvent CBufNetBase   bnb,
TSockId    sockid,
bool &    flag,
bool    condition,
CBufNetBase::TEventType    event
[inline, protected]
 

Pushes a system message into bnb's receive queue, if the flags meets the condition, then resets the flag and returns true.

You can either specify a sockid (for server) or InvalidSockId (for client).

Definition at line 135 of file buf_sock.h.

References asString, condition, nlassert, nldebug, and NLNET::TSockId.

Referenced by NLNET::CServerBufSock::advertiseConnection, and advertiseDisconnection.

uint64 NLNET::CBufSock::appId   const [inline]
 

Returns the application identifier.

Definition at line 63 of file buf_sock.h.

References _AppId.

string NLNET::CBufSock::asString   const
 

Returns a string with the characteristics of the object.

Definition at line 325 of file buf_sock.cpp.

References Sock, and typeStr.

Referenced by advertiseSystemEvent, flush, and NLNET::CServerBufSock::receivePart.

void NLNET::CBufSock::connect const CInetAddress   addr,
bool    nodelay,
bool    connectedstate
[protected]
 

Connects to the specified addr; set connectedstate to true if no connection advertising is needed.

Definition at line 291 of file buf_sock.cpp.

References _ConnectedState, _KnowConnected, addr, nlassert, ReceiveNextValue, SendNextValue, and Sock.

bool NLNET::CBufSock::connectedState   const [inline, protected]
 

Returns the "logically connected" state (changed when processing a connection/disconnection callback).

Definition at line 237 of file buf_sock.h.

References _ConnectedState.

void NLNET::CBufSock::disconnect bool    connectedstate [protected]
 

Disconnects; set connectedstate to false if no disconnection advertising is needed.

Definition at line 311 of file buf_sock.cpp.

References _ConnectedState, _KnowConnected, nlassert, ReceiveNextValue, SendNextValue, and Sock.

bool NLNET::CBufSock::flush   [protected]
 

Forces 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()

Definition at line 138 of file buf_sock.cpp.

References _ReadyToSendBuffer, _RTSBIndex, asString, NLMISC::CObjectVector< uint8 >::clear, NLMISC::CBufFIFO::empty, NLMISC::CBufFIFO::front, NLMISC::CObjectVector< uint8 >::getPtr, nlassert, nlassertex, nldebug, NLMISC::CBufFIFO::pop, res, NLMISC::CObjectVector< uint8 >::resize, SendFifo, NLMISC::CObjectVector< uint8 >::size, Sock, and NLNET::TBlockSize.

Referenced by update.

bool NLNET::CBufSock::pushBuffer const NLMISC::CMemStream   buffer [inline, protected]
 

Pushes a buffer to the send queue and update, or returns false if the socket is not physically connected the or an error occured during sending.

Definition at line 178 of file buf_sock.h.

References NLMISC::CMemStream::length, nlassert, nlwarning, NLMISC::CBufFIFO::push, res, SendFifo, Sock, and update.

void NLNET::CBufSock::setAppId uint64    id [inline]
 

Sets the application identifier.

Definition at line 60 of file buf_sock.h.

References _AppId, and id.

void NLNET::CBufSock::setConnectedState bool    connectedstate [inline, protected]
 

Sets the "logically connected" state (changed when processing a connection/disconnection callback).

Definition at line 234 of file buf_sock.h.

References _ConnectedState.

void NLNET::CBufSock::setSizeFlushTrigger sint32    size [inline, protected]
 

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 104 of file buf_sock.h.

References _TriggerSize.

void NLNET::CBufSock::setTimeFlushTrigger sint32    ms [protected]
 

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 232 of file buf_sock.cpp.

References _LastFlushTime, _TriggerTime, and nlassert.

virtual std::string NLNET::CBufSock::typeStr   const [inline, protected, virtual]
 

Returns "CLT " (client).

Reimplemented in NLNET::CServerBufSock.

Definition at line 115 of file buf_sock.h.

Referenced by asString.

bool NLNET::CBufSock::update   [protected]
 

Update the network sending (call this method evenly). Returns false if an error occured.

Definition at line 243 of file buf_sock.cpp.

References _LastFlushTime, _TriggerSize, _TriggerTime, flush, nlassert, SendFifo, NLMISC::CBufFIFO::size, and NLMISC::TTime.

Referenced by pushBuffer.


Friends And Related Function Documentation

friend class CBufClient [friend]
 

Definition at line 78 of file buf_sock.h.

friend class CBufServer [friend]
 

Reimplemented in NLNET::CServerBufSock.

Definition at line 79 of file buf_sock.h.

friend class CCallbackClient [friend]
 

Definition at line 83 of file buf_sock.h.

friend class CCallbackNetBase [friend]
 

Definition at line 85 of file buf_sock.h.

friend class CCallbackServer [friend]
 

Definition at line 84 of file buf_sock.h.

friend class CClientReceiveTask [friend]
 

Definition at line 80 of file buf_sock.h.

friend class CServerReceiveTask [friend]
 

Reimplemented in NLNET::CServerBufSock.

Definition at line 81 of file buf_sock.h.


Member Data Documentation

uint64 NLNET::CBufSock::_AppId [private]
 

Definition at line 262 of file buf_sock.h.

Referenced by appId, setAppId, and ~CBufSock.

bool NLNET::CBufSock::_ConnectedState [private]
 

Definition at line 265 of file buf_sock.h.

Referenced by connect, connectedState, disconnect, setConnectedState, and ~CBufSock.

bool NLNET::CBufSock::_KnowConnected [protected]
 

Definition at line 246 of file buf_sock.h.

Referenced by NLNET::CServerBufSock::advertiseConnection, advertiseDisconnection, connect, disconnect, and ~CBufSock.

NLMISC::TTime NLNET::CBufSock::_LastFlushTime [private]
 

Definition at line 255 of file buf_sock.h.

Referenced by CBufSock, setTimeFlushTrigger, update, and ~CBufSock.

NLMISC::CObjectVector<uint8> NLNET::CBufSock::_ReadyToSendBuffer [private]
 

Definition at line 259 of file buf_sock.h.

Referenced by flush, and ~CBufSock.

TBlockSize NLNET::CBufSock::_RTSBIndex [private]
 

Definition at line 260 of file buf_sock.h.

Referenced by flush, and ~CBufSock.

sint32 NLNET::CBufSock::_TriggerSize [private]
 

Definition at line 257 of file buf_sock.h.

Referenced by setSizeFlushTrigger, update, and ~CBufSock.

NLMISC::TTime NLNET::CBufSock::_TriggerTime [private]
 

Definition at line 256 of file buf_sock.h.

Referenced by setTimeFlushTrigger, update, and ~CBufSock.

std::string NLNET::CBufSock::AuthorizedCallback
 

Little tricky but this string is used by Layer4 to know which callback is authorized. This is empty when all callback are authorized.

Definition at line 70 of file buf_sock.h.

Referenced by ~CBufSock.

uint32 NLNET::CBufSock::ReceiveNextValue
 

Definition at line 74 of file buf_sock.h.

Referenced by connect, and disconnect.

NLMISC::CBufFIFO NLNET::CBufSock::SendFifo [protected]
 

Definition at line 240 of file buf_sock.h.

Referenced by flush, pushBuffer, and update.

uint32 NLNET::CBufSock::SendNextValue
 

Definition at line 74 of file buf_sock.h.

Referenced by connect, and disconnect.

CTcpSock* NLNET::CBufSock::Sock [protected]
 

Definition at line 243 of file buf_sock.h.

Referenced by asString, CBufSock, connect, disconnect, flush, pushBuffer, NLNET::CServerBufSock::receivePart, and ~CBufSock.


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