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

Client class for layer 1. More...

#include <buf_client.h>

Inheritance diagram for NLNET::CBufClient:

NLNET::CBufNetBase NLNET::CCallbackClient List of all members.

Public Methods

 CBufClient (bool nodelay=true, bool replaymode=false)
 Constructor. Set nodelay to true to disable the Nagle buffering algorithm (see CTcpSock documentation). More...

virtual ~CBufClient ()
 Destructor. More...

void connect (const CInetAddress &addr)
 Connects to the specified host. More...

void disconnect (bool quick=false)
 Disconnects the remote host and empties the receive queue. More...

void send (const NLMISC::CMemStream &buffer)
 Sends a message to the remote host (in fact the message is buffered into the send queue). More...

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

void receive (NLMISC::CMemStream &buffer)
 Receives next block of data in the specified buffer (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 () const
void setTimeFlushTrigger (sint32 ms)
 Sets the time flush trigger (in millisecond). More...

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

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

bool connected () const
 Returns true if the connection is still connected (changed when a disconnection event has reached the front of the receive queue, just before calling the disconnection callback if there is one). More...

const CInetAddressremoteAddress () const
 Returns the address of the remote host. More...

uint64 bytesDownloaded () const
 Returns the number of bytes downloaded (read or still in the receive buffer) since the latest connection. More...

uint64 bytesUploaded () const
 Returns the number of bytes uploaded (flushed) since the latest connection. More...

uint64 newBytesDownloaded ()
 Returns the number of bytes downloaded since the previous call to this method. More...

uint64 newBytesUploaded ()
 Returns the number of bytes uploaded since the previous call to this method. More...

TSockId id () const
 Returns the id of the connection. More...


Protected Attributes

CBufSock_BufSock
 Send buffer and connection. More...

bool _NoDelay
 True when the Nagle algorithm must be disabled (TCP_NODELAY). More...

uint64 _PrevBytesDownloaded
 Previous number of bytes downloaded. More...

uint64 _PrevBytesUploaded
 Previous number of bytes uploaded. More...


Private Attributes

CClientReceiveTask_RecvTask
 Receive task. More...

NLMISC::IThread_RecvThread
 Receive thread. More...


Friends

class CClientReceiveTask

Detailed Description

Client class for layer 1.

Active connection with packet scheme and buffering. 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(), bytesUploaded(), newBytesUploaded()

receive(), <- receive buffer <- receive thread, dataAvailable(), bytesDownloaded(), newBytesDownloaded() disconnection callback

Author:
Olivier Cado , Nevrax France
Date:
2001

Definition at line 91 of file buf_client.h.


Constructor & Destructor Documentation

NLNET::CBufClient::CBufClient bool    nodelay = true,
bool    replaymode = false
 

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

Definition at line 54 of file buf_client.cpp.

References _BufSock, _RecvTask, CClientReceiveTask, and nlnettrace.

NLNET::CBufClient::~CBufClient   [virtual]
 

Destructor.

Definition at line 387 of file buf_client.cpp.

References _BufSock, _RecvTask, _RecvThread, disconnect, nlassert, nldebug, nlnettrace, and NLMISC::IThread::wait.


Member Function Documentation

uint64 NLNET::CBufClient::bytesDownloaded   const [inline]
 

Returns the number of bytes downloaded (read or still in the receive buffer) since the latest connection.

Definition at line 163 of file buf_client.h.

References _BufSock.

Referenced by newBytesDownloaded.

uint64 NLNET::CBufClient::bytesUploaded   const [inline]
 

Returns the number of bytes uploaded (flushed) since the latest connection.

Definition at line 166 of file buf_client.h.

References _BufSock.

Referenced by newBytesUploaded.

void NLNET::CBufClient::connect const CInetAddress   addr
 

Connects to the specified host.

Reimplemented in NLNET::CCallbackClient.

Definition at line 82 of file buf_client.cpp.

References _BufSock, _NoDelay, _PrevBytesDownloaded, _PrevBytesUploaded, _RecvTask, _RecvThread, addr, nlassert, nlnettrace, and NLMISC::IThread::start.

bool NLNET::CBufClient::connected   const [inline]
 

Returns true if the connection is still connected (changed when a disconnection event has reached the front of the receive queue, just before calling the disconnection callback if there is one).

Reimplemented in NLNET::CCallbackClient.

Definition at line 157 of file buf_client.h.

References _BufSock.

bool NLNET::CBufClient::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::CCallbackClient.

Definition at line 130 of file buf_client.cpp.

References _BufSock, NLNET::CBufNetBase::argOfDisconnectionCallback, NLNET::CFifoAccessor, NLNET::CBufNetBase::dataAvailableFlag, NLNET::CBufNetBase::disconnectionCallback, id, nldebug, nlerror, nlinfo, NLNET::CBufNetBase::receiveQueue, and NLNET::CBufNetBase::setDataAvailableFlag.

void NLNET::CBufClient::disconnect bool    quick = false
 

Disconnects the remote host and empties the receive queue.

Before that, flushes pending data to send unless quick is true. The disconnection callback will *not* be called. Do not call if the socket is not connected.

Definition at line 308 of file buf_client.cpp.

References _BufSock, NLNET::CFifoAccessor, nlassert, nlnettrace, NLNET::CBufNetBase::receiveQueue, and NLNET::CBufNetBase::setDataAvailableFlag.

Referenced by ~CBufClient.

bool NLNET::CBufClient::flush   [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()

Definition at line 149 of file buf_client.h.

References _BufSock.

uint32 NLNET::CBufClient::getSendQueueSize   const [inline]
 

Definition at line 133 of file buf_client.h.

References _BufSock.

TSockId NLNET::CBufClient::id   const [inline]
 

Returns the id of the connection.

Definition at line 189 of file buf_client.h.

References _BufSock, and NLNET::TSockId.

Referenced by dataAvailable, NLNET::CCallbackClient::getSockId, and NLNET::CCallbackClient::receive.

uint64 NLNET::CBufClient::newBytesDownloaded  
 

Returns the number of bytes downloaded since the previous call to this method.

Definition at line 351 of file buf_client.cpp.

References _PrevBytesDownloaded, bytesDownloaded, and NLNET::updateStatCounter.

uint64 NLNET::CBufClient::newBytesUploaded  
 

Returns the number of bytes uploaded since the previous call to this method.

Definition at line 360 of file buf_client.cpp.

References _PrevBytesUploaded, bytesUploaded, and NLNET::updateStatCounter.

void NLNET::CBufClient::receive NLMISC::CMemStream   buffer
 

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

Definition at line 262 of file buf_client.cpp.

References NLMISC::CMemStream::buffer, NLNET::CFifoAccessor, NLMISC::CMemStream::length, nlassert, nlnettrace, NLNET::CBufNetBase::receiveQueue, NLMISC::CMemStream::resize, and NLNET::CBufNetBase::setDataAvailableFlag.

const CInetAddress& NLNET::CBufClient::remoteAddress   const [inline]
 

Returns the address of the remote host.

Definition at line 160 of file buf_client.h.

References _BufSock.

Referenced by NLNET::CCallbackClient::hostAddress.

void NLNET::CBufClient::send const NLMISC::CMemStream   buffer
 

Sends a message to the remote host (in fact the message is buffered into the send queue).

Reimplemented in NLNET::CCallbackClient.

Definition at line 111 of file buf_client.cpp.

References _BufSock, NLMISC::CMemStream::length, NLNET::CBufNetBase::maxSentBlockSize, nlassert, and nlnettrace.

void NLNET::CBufClient::setSizeFlushTrigger 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 143 of file buf_client.h.

References _BufSock.

void NLNET::CBufClient::setTimeFlushTrigger 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 138 of file buf_client.h.

References _BufSock.

void NLNET::CBufClient::update  
 

Update the network (call this method evenly).

Definition at line 286 of file buf_client.cpp.

References _BufSock.


Friends And Related Function Documentation

friend class CClientReceiveTask [friend]
 

Definition at line 194 of file buf_client.h.

Referenced by CBufClient.


Member Data Documentation

CBufSock* NLNET::CBufClient::_BufSock [protected]
 

Send buffer and connection.

Definition at line 197 of file buf_client.h.

Referenced by bytesDownloaded, bytesUploaded, CBufClient, NLNET::CCallbackClient::connect, connect, connected, dataAvailable, NLNET::CCallbackClient::disconnect, disconnect, flush, getSendQueueSize, id, remoteAddress, send, setSizeFlushTrigger, setTimeFlushTrigger, update, and ~CBufClient.

bool NLNET::CBufClient::_NoDelay [protected]
 

True when the Nagle algorithm must be disabled (TCP_NODELAY).

Definition at line 200 of file buf_client.h.

Referenced by NLNET::CCallbackClient::connect, and connect.

uint64 NLNET::CBufClient::_PrevBytesDownloaded [protected]
 

Previous number of bytes downloaded.

Definition at line 203 of file buf_client.h.

Referenced by NLNET::CCallbackClient::connect, connect, and newBytesDownloaded.

uint64 NLNET::CBufClient::_PrevBytesUploaded [protected]
 

Previous number of bytes uploaded.

Definition at line 206 of file buf_client.h.

Referenced by NLNET::CCallbackClient::connect, connect, and newBytesUploaded.

CClientReceiveTask* NLNET::CBufClient::_RecvTask [private]
 

Receive task.

Definition at line 219 of file buf_client.h.

Referenced by CBufClient, connect, and ~CBufClient.

NLMISC::IThread* NLNET::CBufClient::_RecvThread [private]
 

Receive thread.

Definition at line 222 of file buf_client.h.

Referenced by connect, and ~CBufClient.


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