48 #include <sys/fcntl.h>
53 #include <netinet/in.h>
54 #include <arpa/inet.h>
55 #include <sys/socket.h>
56 #include <sys/ioctl.h>
63 #include <sys/timeb.h>
68 #define ECONNREFUSED WSAECONNREFUSED
69 #define EINPROGRESS WSAEINPROGRESS
70 #define ETIMEDOUT WSAETIMEDOUT
71 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
72 #define ECONNABORTED WSAECONNABORTED
73 #define ENETUNREACH WSAENETUNREACH
83 # include <unicode/ucnv.h>
93 #include <openssl/ssl.h>
94 #include <openssl/err.h>
95 #include <openssl/rand.h>
112 # ifdef _HAS_CSTRING_
113 # define CS_STRING Cstring
115 # define CS_STRING std::string
121 # define CS_DEBUG( f ) std::cerr << __FILE__ << ":" << __LINE__ << " " << f << std::endl
123 # define CS_DEBUG(f) (void)0
129 # define PERROR( f ) __Perror( f, __FILE__, __LINE__ )
131 # define PERROR( f ) (void)0
142 #define CS_INVALID_SOCK INVALID_SOCKET
146 #define CS_INVALID_SOCK -1
149 #ifdef CSOCK_USE_POLL
153 #ifndef _NO_CSOCKET_NS // some people may not want to use a namespace
168 m_pBuffer = (
char * )malloc( iSize );
191 memset( (
struct sockaddr_in * ) &m_saddr,
'\0',
sizeof( m_saddr ) );
193 memset( (
struct sockaddr_in6 * ) &m_saddr6,
'\0',
sizeof( m_saddr6 ) );
195 m_iAFRequire = RAF_ANY;
204 RAF_INET6 = AF_INET6,
210 void SinPort( uint16_t iPort );
211 void SetIPv6(
bool b );
216 in_addr *
GetAddr() {
return( &( m_saddr.sin_addr ) ); }
220 in6_addr *
GetAddr6() {
return( &( m_saddr6.sin6_addr ) ); }
230 sockaddr_in6 m_saddr6;
232 EAFRequire m_iAFRequire;
276 struct addrinfo * m_pAddrRes;
277 struct addrinfo m_cHints;
294 template <
class T>
inline void CS_Delete( T * & p ) {
if( p ) {
delete p; p = NULL; } }
307 void SSLErrors(
const char *filename, uint32_t iLineNum );
331 return( WSAGetLastError() );
345 FD_SET( iSock, set );
350 return( FD_ISSET( iSock, set ) != 0 );
355 FD_CLR( iSock, set );
376 void run( timeval & tNow );
382 void StartMaxCycles(
double dTimeSequence, uint32_t iMaxCycles );
383 void StartMaxCycles(
const timeval& tTimeSequence, uint32_t iMaxCycles );
386 void Start(
double dTimeSequence );
387 void Start(
const timeval& TimeSequence );
398 timeval GetInterval()
const;
399 uint32_t GetMaxCycles()
const;
400 uint32_t GetCyclesLeft()
const;
414 virtual void RunJob();
421 bool m_bActive, m_bPause;
422 timeval m_tTimeSequence;
423 uint32_t m_iMaxCycles, m_iCycles;
443 virtual bool GatherFDsForSelect( std::map< cs_sock_t, short > & miiReadyFds,
long & iTimeoutMS );
450 virtual bool FDsThatTriggered(
const std::map< cs_sock_t, short > & miiReadyFds ) {
return(
true ); }
457 virtual bool CheckFDs(
const std::map< cs_sock_t, short > & miiReadyFds );
464 void Add(
cs_sock_t iFD,
short iMonitorEvents ) { m_miiMonitorFDs[iFD] = iMonitorEvents; }
489 void CleanupFDMonitors();
492 const std::vector<CCron *> &
GetCrons()
const {
return( m_vcCrons ); }
497 virtual void AddCron(
CCron * pcCron );
504 virtual void DelCron(
const CS_STRING & sName,
bool bDeleteAll =
true,
bool bCaseSensitive =
true );
506 virtual void DelCron( uint32_t iPos );
508 virtual void DelCronByAddr(
CCron * pcCron );
510 void CheckFDs(
const std::map< cs_sock_t, short > & miiReadyFds );
511 void AssignFDs( std::map< cs_sock_t, short > & miiReadyFds,
struct timeval * tvtimeout );
541 Csock(
int iTimeout = 60 );
548 Csock(
const CS_STRING & sHostname, uint16_t uPort,
int itimeout = 60 );
551 virtual Csock *GetSockObj(
const CS_STRING & sHostname, uint16_t iPort );
561 virtual void Dereference();
563 virtual void Copy(
const Csock & cCopy );
577 READ_CONNREFUSED = -3,
617 Csock & operator<<( std::ostream & ( *io )( std::ostream & ) );
618 Csock & operator<<( int32_t i );
619 Csock & operator<<( uint32_t i );
620 Csock & operator<<( int64_t i );
621 Csock & operator<<( uint64_t i );
622 Csock & operator<<(
float i );
623 Csock & operator<<(
double i );
629 virtual bool Connect();
639 virtual bool Listen( uint16_t iPort,
int iMaxConns = SOMAXCONN,
const CS_STRING & sBindHost =
"", uint32_t iTimeout = 0,
bool bDetach =
false );
645 virtual bool AcceptSSL();
648 virtual bool SSLClientSetup();
651 virtual bool SSLServerSetup();
659 virtual bool ConnectSSL();
674 virtual bool Write(
const char *data,
size_t len );
684 virtual bool Write(
const CS_STRING & sData );
701 virtual cs_ssize_t Read(
char *data,
size_t len );
706 virtual bool IsConnected()
const;
708 virtual void SetIsConnected(
bool b );
724 void CallSockError(
int iErrno,
const CS_STRING & sDescription =
"" );
726 virtual void ResetTimer();
743 TMO_ALL = TMO_READ|TMO_WRITE|TMO_ACCEPT
748 void SetTimeout(
int iTimeout, uint32_t iTimeoutType = TMO_ALL );
749 void SetTimeoutType( uint32_t iTimeoutType );
750 int GetTimeout()
const;
751 uint32_t GetTimeoutType()
const;
754 virtual bool CheckTimeout( time_t iNow );
760 virtual void PushBuff(
const char *data,
size_t len,
bool bStartAtZero =
false );
772 void SetMaxBufferThreshold( uint32_t iThreshold );
773 uint32_t GetMaxBufferThreshold()
const;
777 void SetType(
int iType );
781 void SetSockName(
const CS_STRING & sName );
785 void SetHostName(
const CS_STRING & sHostname );
789 uint64_t GetStartTime()
const;
791 void ResetStartTime();
794 uint64_t GetBytesRead()
const;
795 void ResetBytesRead();
798 uint64_t GetBytesWritten()
const;
799 void ResetBytesWritten();
802 double GetAvgRead( uint64_t iSample = 1000 );
805 double GetAvgWrite( uint64_t iSample = 1000 );
808 uint16_t GetRemotePort();
811 uint16_t GetLocalPort();
815 void SetPort( uint16_t iPort );
818 void Close( ECloseType eCloseType = CLT_NOW );
821 bool IsClosed() {
return( GetCloseType() != CLT_DONT ); }
824 void NonBlockingIO();
828 void SetSSL(
bool b );
831 void SetCipher(
const CS_STRING & sCipher );
836 void SetPemLocation(
const CS_STRING & sPemFile );
838 void SetPemPass(
const CS_STRING & sPassword );
842 void SetSSLMethod(
int iMethod );
845 void SetSSLObject( SSL *ssl );
846 void SetCTXObject( SSL_CTX *sslCtx );
847 SSL_SESSION * GetSSLSession();
853 bool HasWriteBuffer()
const;
854 void ClearWriteBuffer();
858 bool SslIsEstablished();
861 bool ConnectInetd(
bool bIsSSL =
false,
const CS_STRING & sHostname =
"" );
864 bool ConnectFD(
int iReadFD,
int iWriteFD,
const CS_STRING & sName,
bool bIsSSL =
false, ETConn eDirection = INBOUND );
873 long GetPeerFingerprint(
CS_STRING & sFP );
875 uint32_t GetRequireClientCertFlags();
877 void SetRequiresClientCert(
bool bRequiresCert );
883 virtual void SetParentSockName(
const CS_STRING & sParentName );
891 virtual void SetRate( uint32_t iBytes, uint64_t iMilliseconds );
893 uint32_t GetRateBytes();
894 uint64_t GetRateTime();
927 virtual void ReadData(
const char *data,
size_t len ) {}
938 void EnableReadLine();
939 void DisableReadLine();
951 virtual void ReachedMaxBuffer();
1003 time_t GetTimeSinceLastDataTransaction( time_t iNow = 0 );
1008 time_t GetNextCheckTimeout( time_t iNow = 0 );
1011 virtual int GetPending();
1021 bool CreateSocksFD();
1024 void CloseSocksFD();
1039 int DNSLookup( EDNSLType eDNSLType );
1048 m_address.SetIPv6( b );
1049 m_bindhost.SetIPv6( b );
1054 m_address.SetAFRequire( iAFRequire );
1055 m_bindhost.SetAFRequire( iAFRequire );
1059 bool AllowWrite( uint64_t & iNOW )
const;
1084 virtual int ConvertAddress(
const struct sockaddr_storage * pAddr, socklen_t iAddrLen,
CS_STRING & sIP, uint16_t * piPort );
1087 CSSockAddr * GetCurrentAddr()
const {
return( m_pCurrAddr ); }
1088 void SetAresFinished(
int status ) { m_pCurrAddr = NULL; m_iARESStatus = status; }
1089 ares_channel GetAresChannel() {
return( m_pARESChannel ); }
1096 void SetEncoding(
const CString& sEncoding );
1103 void ShrinkSendBuff();
1104 void IncBuffPos(
size_t uBytes );
1107 uint16_t m_uPort, m_iRemotePort, m_iLocalPort;
1109 int m_iTimeout, m_iConnType, m_iMethod, m_iTcount, m_iMaxConns;
1110 bool m_bUseSSL, m_bIsConnected, m_bBLOCK;
1111 bool m_bsslEstablished, m_bEnableReadLine, m_bPauseRead;
1112 CS_STRING m_shostname, m_sbuffer, m_sSockName, m_sPemFile, m_sCipherType, m_sParentName;
1113 CS_STRING m_sSend, m_sPemPass, m_sLocalIP, m_sRemoteIP;
1114 ECloseType m_eCloseType;
1116 uint64_t m_iMaxMilliSeconds, m_iLastSendTime, m_iBytesRead, m_iBytesWritten, m_iStartTime;
1117 uint32_t m_iMaxBytes, m_iMaxStoredBufferLength, m_iTimeoutType;
1118 size_t m_iLastSend, m_uSendBufferPos;
1121 bool m_bIsIPv6, m_bSkipConnect;
1122 time_t m_iLastCheckTimeoutTime;
1127 SSL_CTX * m_ssl_ctx;
1128 uint32_t m_iRequireClientCertFlags;
1138 cs_sock_t CreateSocket(
bool bListen =
false );
1139 void Init(
const CS_STRING & sHostname, uint16_t uPort,
int iTimeout = 60 );
1142 ECONState m_eConState;
1144 uint32_t m_iCurBindCount, m_iDNSTryCount;
1147 ares_channel m_pARESChannel;
1153 icu::LocalUConverterPointer m_cnvInt, m_cnvIntStrict, m_cnvExt;
1172 m_sHostname = sHostname;
1174 m_iTimeout = iTimeout;
1213 void SetCipher(
const CS_STRING & s ) { m_sCipher = s; }
1258 m_sBindHost = sBindHost;
1260 m_iMaxConns = SOMAXCONN;
1263 m_bDetach = bDetach;
1266 m_iRequireCertFlags = 0;
1288 void SetPort( uint16_t iPort ) { m_iPort = iPort; }
1303 void SetCipher(
const CS_STRING & s ) { m_sCipher = s; }
1310 void SetRequiresClientCert(
bool b ) { m_iRequireCertFlags = ( b ? SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT : 0 ); }
1320 uint32_t m_iTimeout;
1324 CS_STRING m_sPemLocation, m_sPemPass, m_sCipher;
1325 uint32_t m_iRequireCertFlags;
1367 virtual void clear();
1368 virtual void Cleanup();
1370 virtual Csock * GetSockObj(
const CS_STRING & sHostname, uint16_t uPort,
int iTimeout = 60 );
1376 SELECT_TIMEOUT = -2,
1377 SELECT_TRYAGAIN = -3
1396 virtual bool Listen(
const CSListener & cListen,
Csock * pcSock = NULL, uint16_t * piRandPort = NULL );
1400 bool HasFDs()
const;
1407 virtual void Loop();
1424 void DynamicSelectLoop( uint64_t iLowerBounds, uint64_t iUpperBounds, time_t iMaxResolution = 3600 );
1430 virtual void AddSock(
Csock * pcSock,
const CS_STRING & sSockName );
1433 virtual Csock * FindSockByRemotePort( uint16_t iPort );
1436 virtual Csock * FindSockByLocalPort( uint16_t iPort );
1444 virtual std::vector<Csock *> FindSocksByName(
const CS_STRING & sName );
1447 virtual std::vector<Csock *> FindSocksByRemoteHost(
const CS_STRING & sHostname );
1462 virtual void DelSockByAddr(
Csock * pcSock );
1469 virtual void DelSock(
size_t iPos );
1477 virtual bool SwapSockByIdx(
Csock * pNewSock,
size_t iOrginalSockIdx );
1485 virtual bool SwapSockByAddr(
Csock * pNewSock,
Csock * pOrigSock );
1488 uint64_t GetBytesRead()
const;
1491 uint64_t GetBytesWritten()
const;
1500 void FDSetCheck(
cs_sock_t iFd, std::map< cs_sock_t, short > & miiReadyFds, ECheckType eType );
1501 bool FDHasCheck(
cs_sock_t iFd, std::map< cs_sock_t, short > & miiReadyFds, ECheckType eType );
1505 virtual int Select( std::map< cs_sock_t, short > & miiReadyFds,
struct timeval *tvtimeout );
1514 void Select( std::map<Csock *, EMessages> & mpeSocks );
1516 timeval GetDynamicSleepTime(
const timeval& tNow,
const timeval& tMaxResolution )
const;
1519 virtual void SelectSock( std::map<Csock *, EMessages> & mpeSocks, EMessages eErrno,
Csock * pcSock );
1527 uint64_t m_iCallTimeouts;
1528 uint64_t m_iBytesRead;
1529 uint64_t m_iBytesWritten;
1530 uint64_t m_iSelectWait;
1548 return(
new T( sHostname, uPort, iTimeout ) );
1552 #ifndef _NO_CSOCKET_NS
void CSAdjustTVTimeout(struct timeval &tv, long iTimeoutMS)
adjusts tv with a new timeout if iTimeoutMS is smaller
void SetRequireClientCertFlags(unsigned int iRequireCertFlags)
bitwise flags, 0 means don't require cert, SSL_VERIFY_PEER verifies peers, SSL_VERIFY_FAIL_IF_NO_PEER...
Definition: Csocket.h:1312
void SSLErrors(const char *filename, uint32_t iLineNum)
const CS_STRING & GetBindHost() const
Definition: Csocket.h:1185
int GetCsockClassIdx()
used to retrieve the context position of the socket to its associated ssl connection. Setup once in InitSSL() via SSL_get_ex_new_index
virtual ~CCron()
Definition: Csocket.h:373
simple class to share common code to both TSockManager and Csock
Definition: Csocket.h:482
void MonitorFD(CSMonitorFD *pMonitorFD)
add an FD set to monitor
Definition: Csocket.h:514
ssize_t cs_ssize_t
Definition: Csocket.h:145
Ease of use templated socket manager.
Definition: Csocket.h:1541
Definition: Csocket.h:202
virtual void ReadPaused()
This gets called every iteration of CSocketManager::Select() if the socket is ReadPaused.
Definition: Csocket.h:991
void SetIPv6(bool b)
Definition: Csocket.h:1045
void SetBindHost(const CS_STRING &s)
sets the hostname to bind to (vhost support)
Definition: Csocket.h:1202
void SetBindHost(const CS_STRING &sBindHost)
sets the host to bind to
Definition: Csocket.h:1292
Definition: Csocket.h:1232
CSCharBuffer(size_t iSize)
Definition: Csocket.h:166
Csock * GetCsockFromCTX(X509_STORE_CTX *pCTX)
returns the sock object associated to the particular context. returns NULL on failure or if not avail...
const CS_STRING & GetBindHost() const
Definition: Csocket.h:1026
void ShutdownCsocket()
Shutdown and release global allocated memory.
virtual void SockError(int iErrno, const CS_STRING &sDescription)
A sock error occured event.
Definition: Csocket.h:959
const CS_STRING & GetSockName() const
Definition: Csocket.h:1274
void SetTimeout(uint32_t i)
sets the listen timeout. The listener class will close after timeout has been reached if not 0 ...
Definition: Csocket.h:1298
this function is a wrapper around getaddrinfo (for ipv6)
Definition: Csocket.h:253
CS_STRING m_sSockName
Definition: Csocket.h:1222
ESSLMethod
Definition: Csocket.h:589
virtual T * GetSockObj(const CS_STRING &sHostname, uint16_t uPort, int iTimeout=60)
Definition: Csocket.h:1546
void Add(cs_sock_t iFD, short iMonitorEvents)
adds a file descriptor to be monitored
Definition: Csocket.h:464
bool GetIPv6() const
Definition: Csocket.h:1044
void SetConState(ECONState eState)
sets the connection state to eState
Definition: Csocket.h:1018
EAFRequire GetAFRequire() const
Definition: Csocket.h:224
bool TFD_ISSET(cs_sock_t iSock, fd_set *set)
Definition: Csocket.h:348
void SetAFRequire(EAFRequire iWhich)
Definition: Csocket.h:223
virtual ~CSSockAddr()
Definition: Csocket.h:197
CSSockAddr::EAFRequire GetAFRequire() const
Definition: Csocket.h:1279
void Remove(cs_sock_t iFD)
removes this fd from monitoring
Definition: Csocket.h:466
const CS_STRING & GetPemLocation() const
Definition: Csocket.h:1193
ETConn
Definition: Csocket.h:565
bool m_bEnabled
Definition: Csocket.h:474
bool m_bRunOnNextCall
if set to true, RunJob() gets called on next invocation of run() despite the timeout ...
Definition: Csocket.h:417
void SetTimeout(int i)
sets the connection timeout
Definition: Csocket.h:1206
uint16_t GetPort() const
Definition: Csocket.h:1273
Definition: Csocket.h:1330
virtual bool FDsThatTriggered(const std::map< cs_sock_t, short > &miiReadyFds)
called when there are fd's belonging to this class that have triggered
Definition: Csocket.h:450
char * operator()()
Definition: Csocket.h:174
EFRead
Definition: Csocket.h:572
Ease of use self deleting char * class.
Definition: Csocket.h:163
EFSelect
Definition: Csocket.h:581
virtual void Connected()
Override these functions for an easy interface when using the Socket Manager Don't bother using these...
Definition: Csocket.h:903
ECONState
Definition: Csocket.h:597
const CS_STRING & GetCipher() const
Definition: Csocket.h:1192
uint32_t GetTimeout() const
Definition: Csocket.h:1278
virtual ~CSMonitorFD()
Definition: Csocket.h:435
Definition: Csocket.h:300
void SetDetach(bool b)
Definition: Csocket.h:1271
CSSockAddr::EAFRequire m_iAFrequire
Definition: Csocket.h:1226
void SetPemLocation(const CS_STRING &s)
set the location of the pemfile
Definition: Csocket.h:1306
this lookup is for the vhost bind
Definition: Csocket.h:1031
void SetSockName(const CS_STRING &s)
sets the name of the socket, used for reference, ie in FindSockByName()
Definition: Csocket.h:1200
void CS_Delete(T *&p)
Definition: Csocket.h:294
virtual void SSLFinishSetup(SSL *pSSL)
Gets called immediatly after the m_ssl member is setup and initialized, useful if you need to assign ...
Definition: Csocket.h:998
const CS_STRING & GetHostname() const
Definition: Csocket.h:1183
void SetSelectTimeout(uint64_t iTimeout)
Set the Select Timeout in MICROSECONDS ( 1000 == 1 millisecond ) Setting this to 0 will cause no time...
Definition: Csocket.h:1456
bool GetIPv6() const
Definition: Csocket.h:212
int GetMaxConns() const
Definition: Csocket.h:1277
ECloseType
Definition: Csocket.h:608
in_addr * GetAddr()
Definition: Csocket.h:216
const CS_STRING & GetBindHost() const
Definition: Csocket.h:1275
options for creating a connection
Definition: Csocket.h:1162
void SetAFRequire(CSSockAddr::EAFRequire iAFRequire)
sets the AF family type required
Definition: Csocket.h:1210
CSSockAddr::EAFRequire GetAFRequire() const
Definition: Csocket.h:1189
Basic socket class.
Definition: Csocket.h:537
void SetAFRequire(CSSockAddr::EAFRequire iAFRequire)
sets the AF family type required
Definition: Csocket.h:1300
const CS_STRING & GetPemPass() const
Definition: Csocket.h:1283
virtual void Timeout()
Override these functions for an easy interface when using the Socket Manager Don't bother using these...
Definition: Csocket.h:919
virtual ~CSListener()
Definition: Csocket.h:1269
bool m_bIsSSL
Definition: Csocket.h:1225
const CS_STRING & GetCipher() const
Definition: Csocket.h:1281
String class that is used inside ZNC.
Definition: ZNCString.h:67
ECompType
Definition: Csocket.h:297
#define CS_STRING
Definition: Csocket.h:115
socklen_t GetSockAddrLen6()
Definition: Csocket.h:218
void SetPort(uint16_t iPort)
sets the port to listen on. Set to 0 to listen on a random port
Definition: Csocket.h:1288
void SetMaxConns(int i)
set max connections as called by accept()
Definition: Csocket.h:1296
virtual ~CSConnection()
Definition: Csocket.h:1181
CSMonitorFD()
Definition: Csocket.h:434
uint16_t GetPort() const
Definition: Csocket.h:1186
CSConnection(const CS_STRING &sHostname, uint16_t iPort, int iTimeout=60)
Definition: Csocket.h:1170
time_t GetLastCheckTimeout()
Definition: Csocket.h:1005
uint16_t m_iPort
Definition: Csocket.h:1223
timeval GetNextRun() const
returns the timestamp of the next estimated run time. Note that it may not run at this EXACT time...
Definition: Csocket.h:409
void SetPemPass(const CS_STRING &s)
set the pemfile pass
Definition: Csocket.h:1218
int GetTimeout() const
Definition: Csocket.h:1187
virtual ~TSocketManager()
Definition: Csocket.h:1545
int cs_sock_t
Definition: Csocket.h:144
const uint32_t CS_BLOCKSIZE
Definition: Csocket.h:293
options container to create a listener
Definition: Csocket.h:1247
bool InitCsocket()
This does all the csocket initialized inclusing InitSSL() and win32 specific initializations, only needs to be called once.
int GetErrno()
return the last known error as set by this class
Definition: Csocket.h:1450
CSSSListener(uint16_t iPort, const CS_STRING &sBindHost="")
Definition: Csocket.h:1333
virtual bool ConnectionFrom(const CS_STRING &sHost, uint16_t iPort)
Override these functions for an easy interface when using the Socket Manager Don't bother using these...
Definition: Csocket.h:970
const CS_STRING & GetPemLocation() const
Definition: Csocket.h:1282
bool IsClosed()
Definition: Csocket.h:821
void SetSkipConnect(bool b)
Definition: Csocket.h:1062
std::vector< CSMonitorFD * > m_vcMonitorFD
Definition: Csocket.h:518
this is the main cron job class
Definition: Csocket.h:369
uint64_t GetSelectTimeout()
Get the Select Timeout in MICROSECONDS ( 1000 == 1 millisecond )
Definition: Csocket.h:1453
bool IsEnabled() const
Definition: Csocket.h:470
ECONState GetConState() const
returns the current connection state
Definition: Csocket.h:1016
void SetHostname(const CS_STRING &s)
sets the hostname to connect to
Definition: Csocket.h:1198
void SetPemPass(const CS_STRING &s)
set the pemfile pass
Definition: Csocket.h:1308
virtual void Listening(const CS_STRING &sBindIP, uint16_t uPort)
called when type is LISTENER and the listening port is up and running
Definition: Csocket.h:977
Definition: Csocket.h:301
void SetSockName(const CS_STRING &sSockName)
sets the sock name for later reference (ie FindSockByName)
Definition: Csocket.h:1290
virtual void ReadData(const char *data, size_t len)
Override these functions for an easy interface when using the Socket Manager Don't bother using these...
Definition: Csocket.h:927
socklen_t GetSockAddrLen()
Definition: Csocket.h:214
virtual void ReadLine(const CS_STRING &sLine)
Override these functions for an easy interface when using the Socket Manager Don't bother using these...
Definition: Csocket.h:936
virtual void Disconnected()
Override these functions for an easy interface when using the Socket Manager Don't bother using these...
Definition: Csocket.h:911
sockaddr_in6 * GetSockAddr6()
Definition: Csocket.h:219
void SetPort(uint16_t i)
sets the port to connect to
Definition: Csocket.h:1204
sockaddr wrapper.
Definition: Csocket.h:185
void SetAFRequire(CSSockAddr::EAFRequire iAFRequire)
Definition: Csocket.h:1052
void __Perror(const CS_STRING &s, const char *pszFile, uint32_t iLineNo)
CSSSLConnection(const CS_STRING &sHostname, uint16_t iPort, int iTimeout=60)
Definition: Csocket.h:1235
bool HasReadLine() const
returns the value of m_bEnableReadLine, if ReadLine is enabled
Definition: Csocket.h:941
int GetAddrInfo(const CS_STRING &sHostname, Csock *pSock, CSSockAddr &csSockAddr)
backwards compatible wrapper around CGetAddrInfo and gethostbyname
CSockCommon()
Definition: Csocket.h:485
CSSockAddr()
Definition: Csocket.h:188
EDNSLType
Definition: Csocket.h:1029
const CS_STRING & GetPemPass() const
Definition: Csocket.h:1194
TSocketManager()
Definition: Csocket.h:1544
CSListener(uint16_t iPort, const CS_STRING &sBindHost="", bool bDetach=false)
Definition: Csocket.h:1255
void TFD_ZERO(fd_set *set)
wrappers for FD_SET and such to work in templates.
Definition: Csocket.h:338
bool GetIsSSL() const
Definition: Csocket.h:1188
bool GetDetach() const
Definition: Csocket.h:1272
EAFRequire
Definition: Csocket.h:200
int(* FPCertVerifyCB)(int, X509_STORE_CTX *)
Definition: Csocket.h:523
void SetBindHost(const CS_STRING &sBindHost)
Definition: Csocket.h:1027
void SetRequireClientCertFlags(uint32_t iRequireClientCertFlags)
bitwise flags, 0 means don't require cert, SSL_VERIFY_PEER verifies peers, SSL_VERIFY_FAIL_IF_NO_PEER...
Definition: Csocket.h:879
void SetCertVerifyCB(FPCertVerifyCB pFP)
Definition: Csocket.h:849
int m_iTimeout
Definition: Csocket.h:1224
const CS_STRING & GetSockName() const
Definition: Csocket.h:1184
in6_addr * GetAddr6()
Definition: Csocket.h:220
void SetIsSSL(bool b)
set to true to enable SSL
Definition: Csocket.h:1208
void TFD_SET(cs_sock_t iSock, fd_set *set)
Definition: Csocket.h:343
virtual void ConnectionRefused()
Override these functions for an easy interface when using the Socket Manager Don't bother using these...
Definition: Csocket.h:987
ECloseType GetCloseType()
returns int of type to close
Definition: Csocket.h:820
Best class to use to interact with the sockets.
Definition: Csocket.h:1362
bool GetIsSSL() const
Definition: Csocket.h:1276
void DisableMonitor()
causes this monitor to be removed
Definition: Csocket.h:468
int GetMaxConns() const
returns the number of max pending connections when type is LISTENER
Definition: Csocket.h:1093
std::map< cs_sock_t, short > m_miiMonitorFDs
Definition: Csocket.h:473
void SetPemLocation(const CS_STRING &s)
set the location of the pemfile
Definition: Csocket.h:1216
ECheckType
this is a strict wrapper around C-api select(). Added in the event you need to do special work here ...
Definition: Csocket.h:1494
CS_STRING m_sPemPass
Definition: Csocket.h:1228
std::vector< CCron * > m_vcCrons
Definition: Csocket.h:517
int GetSockError()
Definition: Csocket.h:328
Class to tie sockets to for monitoring by Csocket at either the Csock or TSockManager.
Definition: Csocket.h:431
EMessages
Definition: Csocket.h:1372
Definition: Csocket.h:299
~CSCharBuffer()
Definition: Csocket.h:170
bool InitSSL(ECompType eCompressionType=CT_NONE)
You HAVE to call this in order to use the SSL library, calling InitCsocket() also calls this so unles...
void TFD_CLR(cs_sock_t iSock, fd_set *set)
Definition: Csocket.h:353
void SetRequiresClientCert(bool b)
set to true if require a client certificate (deprecated
Definition: Csocket.h:1310
void SetIsSSL(bool b)
set to true to enable SSL
Definition: Csocket.h:1294
uint32_t GetRequireClientCertFlags() const
Definition: Csocket.h:1284
sockaddr_in * GetSockAddr()
Definition: Csocket.h:215
const std::vector< CCron * > & GetCrons() const
returns a const reference to the crons associated to this socket
Definition: Csocket.h:492