Logo Search packages:      
Sourcecode: znc version File versions

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>

Author:
Jim Hull <imaginos@imaginos.net>

Definition at line 1192 of file Csocket.h.


Public Types

enum  EMessages { SUCCESS = 0, SELECT_ERROR = -1, SELECT_TIMEOUT = -2, SELECT_TRYAGAIN = -3 }

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)
 delete cron(s) by name
virtual void DelCronByAddr (CCron *pcCron)
 delete cron by address
virtual void DelSock (u_int iPos)
virtual void DelSockByAddr (T *pcSock)
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_int 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_int iTimeout)

Private Member Functions

virtual void Cron ()
 these crons get ran and checked in Loop()
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_int 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