Logo Search packages:      
Sourcecode: znc version File versions  Download package

TSocketManager< T > Class Template Reference

#include <Csocket.h>

List of all members.

Detailed Description

template<class T>
class TSocketManager< T >

Best class to use to interact with the sockets.

handles SSL and NON Blocking IO Its a template class since Csock derives need to be new'd correctly Makes it easier to use overall Rather then use it directly, you'll probably get more use deriving from it Another thing to note, is that all sockets are deleted implicitly, so obviously you cant pass in Csock classes created on the stack. For those of you who don't know STL very well, the reason I did this is because whenever you add to certain stl containers (ie vector, or map), its completely rebuilt using the copy constructor on each element. That then means the constructor and destructor are called on every item in the container. Not only is this more overhead then just moving pointers around, its dangerous as if you have an object that is newed and deleted in the destructor the value of its pointer is copied in the default copy constructor. This means everyone has to know better and create a copy constructor, or I just make everyone new their object :)

class CBlahSock : public TSocketManager<SomeSock>

Jim Hull <imaginos@imaginos.net>

Definition at line 1255 of file Csocket.h.

Public Types


Public Member Functions

virtual void AddCron (CCron *pcCron)
 add a cronjob at the manager level
virtual void AddSock (T *pcSock, const CS_STRING &sSockName)
virtual void Cleanup ()
void clear ()
bool Connect (const CSConnection &cCon, T *pcSock=NULL)
virtual void DelCron (u_int iPos)
 delete cron by idx
virtual void DelCron (const CS_STRING &sName, bool bDeleteAll=true, bool bCaseSensitive=true)
 deletes a cron by name
virtual void DelCronByAddr (CCron *pcCron)
 delete cron by address
virtual void DelSock (u_int iPos)
virtual void DelSockByAddr (T *pcSock)
void DynamicSelectLoop (u_long iLowerBounds, u_long iUpperBounds, time_t iMaxResolution=3600)
 this is similar to loop, except that it dynamically adjusts the select time based on jobs and timeouts in sockets
virtual T * FindSockByFD (int iFD)
 returns a pointer to the FIRST sock found by filedescriptor or NULL on no match
virtual T * FindSockByLocalPort (u_short iPort)
 returns a pointer to the FIRST sock found by port or NULL on no match
virtual T * FindSockByName (const CS_STRING &sName)
 returns a pointer to the FIRST sock found by name or NULL on no match
virtual T * FindSockByRemotePort (u_short iPort)
 returns a pointer to the FIRST sock found by port or NULL on no match
virtual std::vector< T * > FindSocksByName (const CS_STRING &sName)
virtual std::vector< T * > FindSocksByRemoteHost (const CS_STRING &sHostname)
 returns a vector of pointers to socks with sHostname as being connected
unsigned long long GetBytesRead () const
 Get the bytes read from all sockets current and past.
unsigned long long GetBytesWritten () const
 Get the bytes written to all sockets current and past.
std::vector< CCron * > & GetCrons ()
int GetErrno ()
 return the last known error as set by this class
u_long GetSelectTimeout ()
 Get the Select Timeout in MICROSECONDS ( 1000 == 1 millisecond ).
virtual bool Listen (const CSListener &cListen, T *pcSock=NULL, u_short *piRandPort=NULL)
virtual void Loop ()
void SetSelectTimeout (u_long iTimeout)
virtual bool SwapSockByAddr (Csock *pNewSock, Csock *pOrigSock)
 swaps out a sock with a copy of the original sock
virtual bool SwapSockByIdx (Csock *pNewSock, u_long iOrginalSockIdx)
 swaps out a sock with a copy of the original sock

Private Member Functions

virtual void Cron ()
 these crons get ran and checked in Loop()
time_t GetDynamicSleepTime (time_t iNow, time_t iMaxResolution=3600) const
virtual void Select (std::map< T *, EMessages > &mpeSocks)
virtual void SelectSock (std::map< T *, EMessages > &mpeSocks, EMessages eErrno, T *pcSock)
 internal use only

Private Attributes

EMessages m_errno
unsigned long long m_iBytesRead
unsigned long long m_iBytesWritten
unsigned long long m_iCallTimeouts
u_long m_iSelectWait
std::vector< CCron * > m_vcCrons

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

Generated by  Doxygen 1.6.0   Back to index