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

Csock Class Reference

#include <Csocket.h>

Inherited by CClient, CDCCBounce, CDCCSock, CEmailFolder, CExecSock, CHTTPSock, CIRCSock, CSChatSock, and CSocket.

List of all members.

Detailed Description

Basic Socket Class The most basic level socket class You can use this class directly for quick things or use the socket manager.

See also:
Jim Hull <imaginos@imaginos.net>

Definition at line 409 of file Csocket.h.

Public Types

enum  ECloseType { CLT_DONT = 0, CLT_NOW = 1, CLT_AFTERWRITE = 2 }
enum  ECONState {
enum  EFRead {
enum  EFSelect { SEL_OK = 0, SEL_TIMEOUT = -1, SEL_EAGAIN = -2, SEL_ERR = -3 }
enum  ESSLMethod { SSL23 = 0, SSL2 = 2, SSL3 = 3 }
enum  ETConn { OUTBOUND = 0, LISTENER = 1, INBOUND = 2 }

Public Member Functions

virtual int Accept (CS_STRING &sHost, u_short &iRPort)
 Accept an inbound connection, this is used internally.
virtual bool AcceptSSL ()
 Accept an inbound SSL connection, this is used internally and called after Accept.
virtual void AddCron (CCron *pcCron)
 insert a newly created cron
void BlockIO (bool bBLOCK)
 Set rather to NON Blocking IO on this socket, default is true.
virtual bool CheckTimeout ()
 returns true if the socket has timed out
void ClearWriteBuffer ()
void Close (ECloseType eCloseType=CLT_NOW)
 just mark us as closed, the parent can pick it up
virtual bool Connect (const CS_STRING &sBindHost="", bool bSkipSetup=false)
virtual void Connected ()
bool ConnectFD (int iReadFD, int iWriteFD, const CS_STRING &sName, bool bIsSSL=false, ETConn eDirection=INBOUND)
 Tie this guy to an existing real file descriptor.
bool ConnectInetd (bool bIsSSL=false, const CS_STRING &sHostname="")
 Use this to bind this socket to inetd.
virtual bool ConnectionFrom (const CS_STRING &sHost, u_short iPort)
virtual void ConnectionRefused ()
virtual bool ConnectSSL (const CS_STRING &sBindhost="")
bool CreateSocksFD ()
 grabs fd's for the sockets
virtual void Cron ()
 This has a garbage collecter, and is used internall to call the jobs.
 Csock (const CS_STRING &sHostname, u_short iport, int itimeout=60)
 Csock (int itimeout=60)
 default constructor, sets a timeout of 60 seconds
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
void DisableReadLine ()
virtual void Disconnected ()
int DNSLookup (EDNSLType eDNSLType)
void EnableReadLine ()
 set the value of m_bEnableReadLine to true, we don't want to store a buffer for ReadLine, unless we want it
bool FullSSLAccept ()
 is SSL_accept finished ?
double GetAvgRead (unsigned long long iSample=1000)
 Get Avg Read Speed in sample milliseconds (default is 1000 milliseconds or 1 second).
double GetAvgWrite (unsigned long long iSample=1000)
 Get Avg Write Speed in sample milliseconds (default is 1000 milliseconds or 1 second).
const CS_STRING & GetBindHost () const
unsigned long long GetBytesRead () const
 Gets the amount of data read during the existence of the socket.
unsigned long long GetBytesWritten () const
 Gets the amount of data written during the existence of the socket.
ECloseType GetCloseType ()
 returns int of type to close
ECONState GetConState () const
 returns the current connection state
const CS_STRING & GetHostName ()
 Returns a reference to the host name.
CS_STRING & GetInternalBuffer ()
bool GetIPv6 () const
u_short GetLocalPort ()
 Returns the local port.
u_int GetMaxBufferThreshold ()
const CS_STRING & GetParentSockName ()
virtual int GetPending ()
 return the data imediatly ready for read
u_short GetPort ()
 Returns the port.
u_int GetRateBytes ()
unsigned long long GetRateTime ()
CS_STRING GetRemoteIP ()
u_short GetRemotePort ()
 Returns the remote port.
int & GetRSock ()
 returns a reference to the sock
int & GetSock ()
const CS_STRING & GetSockName ()
 Returns a reference to the socket name.
virtual CsockGetSockObj (const CS_STRING &sHostname, u_short iPort)
bool GetSSL ()
 if this connection type is ssl or not
unsigned long long GetStartTime () const
 Gets the starting time of this socket.
int GetTimeout () const
u_int GetTimeoutType () const
int GetType ()
 Returns the connection type from enum eConnType.
const CS_STRING & GetWriteBuffer ()
 Get the send buffer.
int & GetWSock ()
bool HasReadLine () const
 returns the value of m_bEnableReadLine, if ReadLine is enabled
bool IsClosed ()
virtual bool IsConnected ()
 Tells you if the socket is connected.
bool IsReadPaused ()
virtual bool Listen (u_short iPort, int iMaxConns=SOMAXCONN, const CS_STRING &sBindHost="", u_int iTimeout=0)
void NonBlockingIO ()
 Use this to change your fd's to blocking or none blocking.
Csockoperator<< (double i)
Csockoperator<< (float i)
Csockoperator<< (unsigned long long i)
Csockoperator<< (unsigned long i)
Csockoperator<< (long i)
Csockoperator<< (unsigned int i)
Csockoperator<< (int i)
Csockoperator<< (std::ostream &(*io)(std::ostream &))
Csockoperator<< (const CS_STRING &s)
void PauseRead ()
 will pause/unpause reading on this socket
virtual void PushBuff (const char *data, int len)
virtual void ReachedMaxBuffer ()
virtual int Read (char *data, int len)
virtual void ReadData (const char *data, int len)
virtual void ReadLine (const CS_STRING &sLine)
virtual void ReadPaused ()
virtual int ReadSelect ()
void ResetBytesRead ()
void ResetBytesWritten ()
void ResetStartTime ()
 Resets the start time.
void ResetTimer ()
 resets the time counter
void SetBindHost (const CS_STRING &sBindHost)
void SetConState (ECONState eState)
 sets the connection state to eState
void SetHostName (const CS_STRING &sHostname)
void SetIPv6 (bool b)
virtual void SetIsConnected (bool b)
 Sets the sock, telling it its connected (internal use only).
void SetMaxBufferThreshold (u_int iThreshold)
 sets the max buffered threshold when enablereadline() is enabled
virtual void SetParentSockName (const CS_STRING &sParentName)
 Get the peer's X509 cert.
void SetPort (u_short iPort)
virtual void SetRate (u_int iBytes, unsigned long long iMilliseconds)
void SetRSock (int iSock)
void SetSock (int iSock)
void SetSockName (const CS_STRING &sName)
void SetSSL (bool b)
void SetTimeout (int iTimeout, u_int iTimeoutType=TMO_ALL)
void SetTimeoutType (u_int iTimeoutType)
void SetType (int iType)
bool SetupVHost ()
 this is only used on outbound connections, listeners bind in a different spot
void SetWSock (int iSock)
virtual void SockError (int iErrno)
virtual bool SSLClientSetup ()
 This sets up the SSL Client, this is used internally.
bool SslIsEstablished ()
 is the ssl properly finished (from write no error)
virtual bool SSLServerSetup ()
 This sets up the SSL Server, this is used internally.
virtual void Timeout ()
void UnPauseRead ()
virtual bool Write (const CS_STRING &sData)
virtual bool Write (const char *data, int len)
virtual int WriteSelect ()

Private Member Functions

virtual void Init (const CS_STRING &sHostname, u_short iport, int itimeout=60)
virtual int SOCKET (bool bListen=false)
 Create the socket.

Private Attributes

CSSockAddr m_address
bool m_bBLOCK
bool m_bEnableReadLine
bool m_bFullsslAccept
CSSockAddr m_bindhost
bool m_bIsConnected
bool m_bIsIPv6
bool m_bPauseRead
bool m_bRequireClientCert
bool m_bssl
bool m_bsslEstablished
ECloseType m_eCloseType
ECONState m_eConState
unsigned long long m_iBytesRead
unsigned long long m_iBytesWritten
int m_iConnType
u_int m_iCurBindCount
u_int m_iDNSTryCount
unsigned int m_iLastSend
unsigned long long m_iLastSendTime
u_short m_iLocalPort
unsigned int m_iMaxBytes
unsigned long long m_iMaxMilliSeconds
unsigned int m_iMaxStoredBufferLength
int m_iMethod
u_short m_iport
int m_iReadSock
u_short m_iRemotePort
unsigned long long m_iStartTime
int m_iTcount
int m_itimeout
unsigned int m_iTimeoutType
int m_iWriteSock
CS_STRING m_sBindHost
CS_STRING m_sbuffer
CS_STRING m_sCipherType
CS_STRING m_shostname
CS_STRING m_sParentName
CS_STRING m_sPemFile
CS_STRING m_sPemPass
CS_STRING m_sSockName
std::vector< CCron * > m_vcCrons

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

Generated by  Doxygen 1.6.0   Back to index