Retail products


Traffic interception SDK

Control every TCP/IP network connection

  • Route connections via proxy
  • Redirect connections and modify the data
  • Block connections and applications
SSL interception SDK

View SSL in plaintext and modify it

  • View the SSL stream decrypted in plaintext
  • Redirect SSL connection and modify decrypted data
  • Browser shows "SSL lock" without warnings

Documentation


CTCPSocketAsyncMsg Class Reference

#include <TCPSocketAsyncMsg.h>

Inheritance diagram for CTCPSocketAsyncMsg:
Collaboration diagram for CTCPSocketAsyncMsg:

List of all members.


Public Types

enum  _SocketShutdown { ssReceive, ssSend, ssBoth }
typedef enum
CSocket::_SocketShutdown 
SocketShutdown

Public Member Functions

virtual int ReceiveMsg (char *pData, int iSize, int &iMoreMessages)
virtual int SendMsg (const char *pData, int iSize)
virtual int SendMsg (const char *pData, int iSize, CGenericEvent *pStopEvent)
 CTCPSocketAsyncMsg ()
virtual ~CTCPSocketAsyncMsg ()
virtual SOCKET Detach ()
virtual BOOL Accept (CTCPSocket *pNewSocket)
CTCPSocketAccept ()
virtual BOOL Listen (unsigned long ulBackLog=5)
virtual IP GetBindAddress () const
virtual unsigned short GetBindPort () const
virtual BOOL Bind (IP aSourceAddress, unsigned short usPort)
virtual BOOL Bind (const std::string &rSourceAddress, unsigned short usPort)
BOOL SetConnectionTimeout (unsigned long ulMS)
unsigned long GetConnectionTimeout () const
virtual int Send (const char *pBuffer, unsigned long ulBufferLength)
virtual int Send (IP aDestinationAddress, const char *pBuffer, unsigned long ulBufferLength, unsigned short usDestinationPort=0)
virtual int Send (const std::string &rDestinationAddress, const char *pBuffer, unsigned long ulBufferLength, unsigned short usDestinationPort=0)
virtual BOOL Close ()
virtual int Receive (char *pBuffer, unsigned long ulBufferLength)
virtual int Peek (char *pBuffer, unsigned long ulBufferLength)
virtual BOOL Connect (IP aDestinationAddress, unsigned short usDestinationPort, BOOL bDisableAsync=FALSE, BOOL bForceErrorEvent=FALSE)
virtual BOOL Connect (const std::string &rDestinationAddress, unsigned short usDestinationPort, BOOL bDisableAsync=FALSE, BOOL bForceErrorEvent=FALSE)
virtual BOOL Connect (unsigned short usSourcePort, IP aDestinationAddress, unsigned short usDestinationPort, BOOL bDisableAsync=FALSE, BOOL bForceErrorEvent=FALSE)
virtual BOOL Connect (unsigned short usSourcePort, const std::string &rDestinationAddress, unsigned short usDestinationPort, BOOL bDisableAsync=FALSE, BOOL bForceErrorEvent=FALSE)
virtual BOOL Connect (unsigned short usSourcePort, IP aDestinationAddress, unsigned short usDestinationPort)
virtual BOOL Connect (unsigned short usSourcePort, const std::string &rDestinationAddress, unsigned short usDestinationPort)
virtual BOOL Connect (IP aDestinationAddress, unsigned short usDestinationPort)
virtual BOOL Connect (const std::string &rDestinationAddress, unsigned short usDestinationPort)
virtual BOOL Create ()
BOOL Create (int iProtocol)
void SetLinkedSocket (CTCPSocketAsync *pSocket, CTCPSocketOverider *pOverider)
CTCPSocketOveriderGetOverider () const
 operator const CTCPSocketOverider * () const
BOOL SetNagle (BOOL bNagle)
BOOL IsConnected () const
unsigned char GetProtocol () const
void SetProtocol (unsigned char iProtocol)
BOOL IsRaw () const
BOOL SetReceiveTimeout (unsigned long ulMS)
SOCKET GetHandle () const
BOOL SetBroadcast (BOOL bBroadcast)
BOOL IsCreated () const
BOOL CanWrite () const
BOOL CanRead () const
unsigned short GetPeerPort () const
BOOL Shutdown (SocketShutdown eHow)
long GetPeerAddress () const
void SetTTL (unsigned char ucTTL)
virtual void SetSourceAddress (IP aSourceAddress)
virtual void SetSourceAddress (const std::string &rSourceAddress)
bool operator== (const CSocket &rSocket) const
bool operator< (const CSocket &rSocket) const
int GetLastError () const
void SetLocalLog (CErrorLog *pLog, bool bWriteToMain=false)
void WriteError (const std::string &rClass, const std::string &rMethod, const std::string &rError) const
void WriteMessage (const std::string &rClass, const std::string &rMethod, const std::string &rMessage) const
void DetachedSocketThread ()
void DisableBlockingSend ()
BOOL SetLocalThreadManager (CSocketThreadManagerImp *pManager)
CSocketThreadManagerImpGetThreadManager () const
CSocketThreadManager::TimerID RegisterTimeout (int iMS, CSocketThreadManagerImp::LPTimeoutProc pProc, LPVOID pData, BOOL bClearTimeout=FALSE, CSocketThreadManagerImp::TimerID *pTimer=NULL)
BOOL HasTimeout () const
void DisableEvents (unsigned char ucEvents)
BOOL IsDeleting () const
void SetDeleting ()
BOOL IsClosing () const
void ForceReceiveEvent ()
virtual void DeleteSocketFromThread ()
virtual void DeleteSocketFromThread (DWORD dwTimeToWait)
virtual void DeleteSocketFromThreadWait ()
void AllowBlockedBuffer (BOOL bAllow)
virtual BOOL ReAsync ()
virtual BOOL ReBlock ()
void FreezeThread ()
BOOL DisableAsync ()
BOOL KillTimer ()
BOOL SetTimeout (int iMs)

Static Public Member Functions

static void Shutdown ()
static int GetErrorCode ()
static int GetSystemLastError ()
static BOOL IsInitialized ()
static unsigned long StringToLong (const std::string &rAddress)
static char FAR * LongToString (unsigned long ulAddr)
static std::string LongToStdString (unsigned long ulAddr)
static BOOL InitializeSockets (BOOL bMultiThreaded=TRUE, unsigned long ulNumberOfThreads=10)
static BOOL ShutdownSockets ()
static unsigned long GetNumberOfThreads ()
static BOOL IsMultiThreaded ()
static CGenericCriticalSectionGetGlobalCriticalSection ()
static unsigned long ResolveDNS (const std::string &rAddress)
static BOOL ValidAddress (const std::string &rAddress)
static CErrorHandlerGetSecondaryLog ()
static CErrorHandlerGetThirdLog ()
static void ClearStaticLogs ()
static std::string GetCurrentDateTime ()
static std::string ErrorCodeToString (DWORD dwErrorCode)
static void RegisterError (DWORD dwErrorCode, const std::string &rDescription)
static void SetLog (CErrorLog *pLog)
static void WriteStaticError (const std::string &rClass, const std::string &rMethod, const std::string &rError)
static void WriteStaticMessage (const std::string &rClass, const std::string &rMethod, const std::string &rMessage)
static std::string FormatData (const std::string &rClass, const std::string &rMethod, const std::string &rMsgOrError, bool bError=true)
static void SetCleanTimeout (DWORD dwTimeout)
static CSocketThreadManagerImpCloneThreadManager (unsigned long ulThreads)
static void SimpleMessageMap ()
static void SimpleMessageMap (DWORD dwRunTimeMS)
static void SimpleMessageMap (LPMapProc pProc, BOOL bStopWhenTRUE, DWORD dwSleep)
static char SimpleMessageMapKey (DWORD dwSleep)
static void Initialize ()
static void SetInstance (HINSTANCE hInst)

Protected Member Functions

virtual int SendNoAdd (const char *pBuffer, unsigned long ulBufferLength)
virtual BOOL IsAsyncClass () const
virtual BOOL SetAsync ()
virtual SOCKET GetAsyncHandle () const
virtual BOOL SendBlockedBuffer (const CBlockedBuffer::CBlockedData &rData)
virtual BOOL SocketConnected (int iErrorCode, BOOL bNoEvent=FALSE)
virtual BOOL SocketReceive (int iErrorCode, BOOL bNoEvent=FALSE)
virtual BOOL SocketClosed (int iErrorCode, BOOL bNoEvent)
virtual BOOL SocketWrite (int iErrorCode)
BOOL LocalListen (unsigned long ulBackLog)
BOOL LocalConnect (unsigned short usSourcePort, IP aDestinationAddress, unsigned short usDestinationPort, BOOL bDisableAsync, BOOL bForceErrorEvent)
BOOL LocalSocketConnect (int iErrorCode, BOOL bNoEvent)
BOOL LocalSocketReceive (int iErrorCode, BOOL bNoEvent)
BOOL LocalSocketAccept (int iErrorCode, BOOL bNoEvent)
BOOL LocalSocketClose (int iErrorCode, BOOL bNoEvent)
BOOL LocalBind (IP aSourceAddress, unsigned short usPort)
IP LocalGetBindAddress () const
unsigned short LocalGetBindPort () const
BOOL LocalAccept (CTCPSocket *pNewSocket)
void SetConnectionStatus (BOOL bConnected)
void SetAcceptance (CTCPSocket *pNewSocket, SOCKET aSocket, sockaddr_in aAddress) const
void SetConnectedTo (const sockaddr_in &rAddress)
IP GetSourceAddress () const
unsigned char GetTTL () const
BOOL CheckSocketValid () const
void AssignSocket (SOCKET aNewSocket, unsigned char ucProtocol=IPPROTO_TCP)
BOOL ValidSocket () const
virtual void InitializeIP ()
virtual int ReceiveFrom (char *pBuffer, unsigned long ulBufferLength, IP &rIP, unsigned short &rSourcePort)
virtual void NotifyShutdown ()
void RegisterShutdown (CSocketBase *pBase)
void SetLastError (const std::string &rMethod) const
void SetLastError (const std::string &, int iErrorCode) const
void WriteMessage (const std::string &rMethod, const std::string &rMessage) const
const std::string & GetClassName () const
virtual void ReportError (const std::string &rMethod) const
virtual void ReportError (const std::string &rMethod, const std::string &rMessage) const
virtual void ReportError (const std::string &rMethod, const std::string &rMessage, DWORD dwAdditionalData) const
virtual void ReportError (const std::string &rMethod, const std::string &rMessage, const std::string &rAdditionalData) const
virtual void ReportError (const std::string &rMethod, int iErrorCode) const
virtual void ReportError (const std::string &rMethod, const std::string &rMessage, int iErrorCode) const
virtual void ReportErrorOS (const std::string &rMethod, const std::string &rMessage) const
void SetName (const std::string &rName) const
virtual BOOL OnSocketTimeout ()=0
virtual BOOL OnSocketConnect (int iErrorCode)=0
virtual BOOL OnSocketAccept (int iErrorCode)=0
virtual BOOL OnSocketClose (int iErrorCode)=0
virtual BOOL OnSocketOOB (int iErrorCode)=0
virtual BOOL OnSocketWrite (int iErrorCode)=0
virtual BOOL OnSocketReceive (int iErrorCode)=0
BOOL IsBlocking () const
int InternalWSAAsyncSelect (unsigned int wMsg, long lEvent)
void SocketClosing ()
int GetSocketID () const
HWND GetWindowHandle () const
void RemoveSocketFromList ()
void AddSocketToList ()
BOOL IsTimeout () const
BOOL Block ()
CBlockedBufferGetBlockedBuffer () const
virtual BOOL SocketAccept (int iErrorCode, BOOL bNoEvent=FALSE)
BOOL SetSystemTimeout (int iMS)
BOOL KillSystemTimer ()
BOOL HasSystemTimer () const
virtual void OnSocketDelete (CGenericEvent *pEvent=NULL)
virtual void SocketCreated ()
virtual BOOL ClearEvents ()
BOOL IsBlockSend () const
BOOL IsInThread () const
BOOL WaitForBlockEvent () const
void ResetEvent ()

Static Protected Member Functions

static void ReportStaticError (const std::string &rClass, const std::string &rMethod)
static void ReportStaticError (const std::string &rClass, const std::string &rMethod, const std::string &rMessage)
static void ReportStaticError (const std::string &rClass, const std::string &rMethod, const std::string &rMessage, DWORD dwAdditionalData)
static void ReportStaticErrorOS (const std::string &rClass, const std::string &rMethod, const std::string &rMessage)
static CSocketThreadManagerImpGetSocketThreadManager ()

Static Protected Attributes

static CGenericCriticalSectionm_pCSection = NULL

Friends

class CIPCrafter

Detailed Description

Definition at line 51 of file TCPSocketAsyncMsg.h.


Member Typedef Documentation

typedef MapProc CAsyncSocket::LPMapProc [inherited]

Definition at line 93 of file AsyncSocket.h.

typedef BOOL(* CAsyncSocket::MapProc)() [inherited]


Member Enumeration Documentation

enum CAsyncSocket::_AsyncEvents [inherited]

Enumerator:
aeReceive 
aeSend 
aeOOB 
aeClose 

Definition at line 83 of file AsyncSocket.h.

00084     {
00085         aeReceive=1,
00086         aeSend=2,
00087         aeOOB=4,
00088         aeClose=8
00089     } AsyncEvents;

enum CSocket::_SocketShutdown [inherited]

Enumerator:
ssReceive 
ssSend 
ssBoth 

Definition at line 51 of file Socket.h.

00052     {
00053         ssReceive,
00054         ssSend,
00055         ssBoth
00056     } SocketShutdown;


Constructor & Destructor Documentation

CTCPSocketAsyncMsg::CTCPSocketAsyncMsg (  ) 

Definition at line 55 of file TCPSocketAsyncMsg.cpp.

00055                                        : CTCPSocketAsync(false)
00056 {
00057     //Set our name
00058     SetName(CTCPSocketAsyncMsg_Class);
00059 }

CTCPSocketAsyncMsg::~CTCPSocketAsyncMsg (  )  [virtual]

Definition at line 61 of file TCPSocketAsyncMsg.cpp.

00062 {
00063 }


Member Function Documentation

CTCPSocket * CTCPSocket::Accept (  )  [inherited]

Definition at line 242 of file TCPSocket.cpp.

00243 {
00244     try
00245     {
00246         //Quit if not ok
00247         if (!CheckSocketValid())
00248             return FALSE;
00249 
00250         //First accept the socket
00251         SOCKET aSocket;
00252         
00253         //Where we are connected to
00254         sockaddr_in aConnected;
00255         
00256         //Size of the structure
00257         int iSize;
00258         iSize=sizeof(aConnected);
00259 
00260         //Accept it
00261         aSocket=accept(GetHandle(),
00262                        (sockaddr*)&aConnected,
00263                        &iSize);
00264 
00265         //Is all OK
00266         if (aSocket!=INVALID_SOCKET)
00267         {
00268             //Create the new tcp socket
00269             CTCPSocket* pSocket;
00270             pSocket=new CTCPSocket(aSocket);
00271 
00272             //Set the address
00273             pSocket->SetConnectedTo(aConnected);
00274             pSocket->SetConnectionStatus(TRUE);
00275 
00276             //Done
00277             return pSocket;
00278         }
00279         else
00280         {
00281             //Error
00282             SetLastError("Accept");
00283 
00284             //Exit
00285             return NULL;
00286         }
00287     }
00288     ERROR_HANDLER_RETURN("Accept",NULL)
00289 }

BOOL CTCPSocketAsync::Accept ( CTCPSocket pNewSocket  )  [virtual, inherited]

Reimplemented from CTCPSocket.

Reimplemented in CTCPSocketAsyncSSL.

Definition at line 860 of file TCPSocketAsync.cpp.

00861 {
00862     try
00863     {
00864         if (m_pLinkedSocket)
00865             return m_pLinkedSocket->Accept(pNewSocket);
00866         else
00867             return LocalAccept(pNewSocket);
00868     }
00869     ERROR_HANDLER_RETURN("Accept",FALSE)
00870 }

void CAsyncSocket::AddSocketToList (  )  [protected, inherited]

Definition at line 233 of file AsyncSocket.cpp.

00234 {
00235     try
00236     {
00237         //Allocate our window
00238         AllocateHandle();
00239 
00240         //We are in the list
00241         m_bList=TRUE;
00242     }
00243     ERROR_HANDLER("AddSocketToList")
00244 }

void CAsyncSocket::AllowBlockedBuffer ( BOOL  bAllow  )  [inherited]

Definition at line 681 of file AsyncSocket.cpp.

00682 {
00683     try
00684     {
00685         //Do we have a buffer
00686         if (bAllow && 
00687             !m_pBlockedBuffer)
00688             m_pBlockedBuffer=new CBlockedBuffer(this);
00689         else if (!bAllow && 
00690                  m_pBlockedBuffer)
00691         {
00692             //Delete and reset the blocked buffer
00693             delete m_pBlockedBuffer;
00694             m_pBlockedBuffer=NULL;
00695         }
00696     }
00697     ERROR_HANDLER("AllowBlockedBuffer")
00698 }

void CSocket::AssignSocket ( SOCKET  aNewSocket,
unsigned char  ucProtocol = IPPROTO_TCP 
) [protected, inherited]

Definition at line 500 of file Socket.cpp.

00502 {
00503     try
00504     {
00505         //Sets the protocol
00506         m_ucProtocol=ucProtocol;
00507 
00508         //Binds to a socket
00509         m_aSocket=aNewSocket;
00510     }
00511     ERROR_HANDLER("AssignSocket")
00512 }

BOOL CSocket::Bind ( const std::string &  rSourceAddress,
unsigned short  usPort 
) [virtual, inherited]

Definition at line 318 of file Socket.cpp.

00320 {
00321     try
00322     {
00323         //Quit if not ok
00324         if (!CheckSocketValid())
00325             return FALSE;
00326 
00327         if (rSourceAddress.empty())
00328             return Bind((IP)0,
00329                         usPort);
00330         else
00331             return Bind(inet_addr(rSourceAddress.c_str()),
00332                         usPort);
00333     }
00334     ERROR_HANDLER_RETURN("Bind",FALSE)
00335 }

BOOL CTCPSocketAsync::Bind ( IP  aSourceAddress,
unsigned short  usPort 
) [virtual, inherited]

Reimplemented from CSocket.

Definition at line 783 of file TCPSocketAsync.cpp.

00785 {
00786     try
00787     {
00788         //Do we have a linked socket?
00789         if (m_pLinkedSocket)
00790             //Delegate the call
00791             return m_pLinkedSocket->Bind(aSourceAddress,
00792                                          usPort);
00793         else
00794             return LocalBind(aSourceAddress,
00795                              usPort);
00796     }
00797     ERROR_HANDLER_RETURN("Listen",FALSE)
00798 }

BOOL CAsyncSocket::Block (  )  [protected, inherited]

Definition at line 634 of file AsyncSocket.cpp.

00635 {
00636     try
00637     {
00638         //First disable the events
00639         int iResult;
00640         iResult=WSAAsyncSelect(GetAsyncHandle(),
00641                                GetWindowHandle(),
00642                                0,
00643                                0);
00644 
00645         if (iResult)
00646         {
00647             //Report it
00648             SetLastError("Block");
00649 
00650             //Exit
00651             return FALSE;
00652         }
00653 
00654         unsigned long ulBlocking;
00655         ulBlocking=0;
00656 
00657         //And return to non-blocking
00658         iResult=ioctlsocket(GetAsyncHandle(),
00659                             FIONBIO,
00660                             &ulBlocking);
00661 
00662         if (iResult)
00663         {
00664             //Report it
00665             SetLastError("Block");
00666 
00667             //Exit
00668             return FALSE;
00669         }
00670 
00671         return TRUE;
00672     }
00673     ERROR_HANDLER_RETURN("Block",FALSE)
00674 }

BOOL CSocket::CanRead (  )  const [inherited]

Definition at line 721 of file Socket.cpp.

00722 {
00723     try
00724     {
00725         //Quit if not ok
00726         if (!CheckSocketValid())
00727             return FALSE;
00728 
00729         //Create our structure
00730         fd_set aDescriptor;
00731         FD_ZERO(&aDescriptor);
00732 
00733         //Add our socket
00734         FD_SET(GetHandle(),
00735                &aDescriptor);
00736 
00737         //And create the timeval
00738         timeval aTime;
00739         aTime.tv_sec=0;
00740         aTime.tv_usec=0;
00741 
00742         //And run the select
00743         int iRetVal;
00744         iRetVal=select(NULL,
00745                        &aDescriptor,
00746                        NULL,
00747                        NULL,
00748                        &aTime);
00749 
00750         //Check if we had an error
00751         if (iRetVal==GetErrorCode())
00752         {
00753             //Report it
00754             SetLastError("CanRead");
00755 
00756             //Exit
00757             return FALSE;
00758         }
00759         else
00760             //Check is our socket set
00761             return FD_ISSET(GetHandle(),
00762                             &aDescriptor);
00763     }
00764     ERROR_HANDLER_RETURN("CanRead",FALSE)
00765 }

BOOL CSocket::CanWrite (  )  const [inherited]

Definition at line 767 of file Socket.cpp.

00768 {
00769     try
00770     {
00771         //Quit if not ok
00772         if (!CheckSocketValid())
00773             return FALSE;
00774 
00775         //Create our structure
00776         fd_set aDescriptor;
00777         FD_ZERO(&aDescriptor);
00778 
00779         //Add our socket
00780         FD_SET(GetHandle(),
00781                &aDescriptor);
00782 
00783         //And create the timeval
00784         timeval aTime;
00785         aTime.tv_sec=0;
00786         aTime.tv_usec=0;
00787 
00788         //And run the select
00789         int iRetVal;
00790         iRetVal=select(NULL,
00791                        NULL,
00792                        &aDescriptor,
00793                        NULL,
00794                        &aTime);
00795 
00796         //Check if we had an error
00797         if (iRetVal==GetErrorCode())
00798         {
00799             //Report it
00800             SetLastError("CanWrite");
00801 
00802             //Exit
00803             return FALSE;
00804         }
00805         else
00806             //Check is our socket set
00807             return FD_ISSET(GetHandle(),
00808                             &aDescriptor);
00809     }
00810     ERROR_HANDLER_RETURN("CanWrite",FALSE)
00811 }

BOOL CSocket::CheckSocketValid (  )  const [protected, inherited]

Definition at line 387 of file Socket.cpp.

00388 {
00389     try
00390     {
00391         //Check if socket is invalid
00392         if (!ValidSocket())
00393         {
00394             //Report it
00395             ReportError("CheckSocketValid","Operation made on non existant socket!");
00396 
00397             //Exit
00398             return FALSE;
00399         }   
00400 
00401         //OK
00402         return TRUE;
00403     }
00404     ERROR_HANDLER_RETURN("CheckSocketValid",FALSE)
00405 }

BOOL CAsyncSocket::ClearEvents (  )  [protected, virtual, inherited]

Definition at line 584 of file AsyncSocket.cpp.

00585 {
00586     try
00587     {
00588         //Quit if not ok
00589         if (!CheckAsyncSocketValid())
00590             return FALSE;
00591 
00592         //Do it
00593         return !InternalWSAAsyncSelect(0,0);
00594     }
00595     ERROR_HANDLER_RETURN("ClearEvents",FALSE)
00596 }

void CErrorHandler::ClearStaticLogs (  )  [static, inherited]

Definition at line 680 of file ErrorHandler.cpp.

00681 {
00682     //Delete the logs
00683     delete m_pSecondLevelLog;
00684     m_pSecondLevelLog=NULL;
00685 
00686     delete m_pThirdLevelLog;
00687     m_pThirdLevelLog=NULL;
00688 }

CSocketThreadManagerImp * CAsyncSocket::CloneThreadManager ( unsigned long  ulThreads  )  [static, inherited]

Definition at line 1269 of file AsyncSocket.cpp.

01270 {
01271     try
01272     {
01273         //Do we have a thread manager?
01274         if (!m_pThreadManager ||
01275             !m_pThreadManager->IsInitialized())
01276         {
01277             //Report it
01278             ReportStaticError(CAsyncSocket_Class,"SetLocalThreadManager","Manager is either null or not initialized!");
01279 
01280             //Exit
01281             return NULL;
01282         }
01283 
01284         //Which thread count
01285         unsigned long ulThreadCount;
01286         if (!ulThreads)
01287             ulThreadCount=m_pThreadManager->GetNumberOfThreads();
01288         else
01289             ulThreadCount=ulThreads;
01290 
01291         //Clone it
01292         CSocketThreadManagerImp* pManager;
01293         pManager=new CSocketThreadManagerImp(m_hInstance);
01294         if (!pManager->Initialize(ulThreads))
01295         {
01296             //Report it
01297             ReportStaticError(CAsyncSocket_Class,"CloneThreadManager","Failed to initialize the thread manager!");
01298 
01299             //Delete it
01300             delete pManager;
01301 
01302             //Exit
01303             return NULL;
01304         }
01305         else
01306             return pManager;
01307     }
01308     ERROR_HANDLER_STATIC_RETURN(CAsyncSocket_Class,"CloneThreadManager",NULL)
01309 }

BOOL CTCPSocketAsync::Close (  )  [virtual, inherited]

Reimplemented from CTCPSocket.

Definition at line 510 of file TCPSocketAsync.cpp.

00511 {
00512     try
00513     {
00514         //Quit if not ok
00515         if (!ValidSocket())
00516             return FALSE;
00517 
00518         //Delegate to remove socket
00519         if (m_pLinkedSocket &&
00520             m_bCloseEventsOnly)
00521             m_pLinkedSocket->Close();
00522 
00523         //Kill the timer
00524         CAsyncSocket::SocketClosing();
00525 
00526         //Remove from socket list
00527         RemoveSocketFromList();
00528 
00529         //Done
00530         return CTCPSocket::Close();
00531     }
00532     ERROR_HANDLER_RETURN("Close",FALSE)
00533 }

BOOL CTCPSocket::Connect ( const std::string &  rDestinationAddress,
unsigned short  usDestinationPort 
) [virtual, inherited]

Definition at line 115 of file TCPSocket.cpp.

00117 {
00118     try
00119     {
00120         return Connect(0,
00121                        rDestinationAddress,
00122                        usDestinationPort);
00123     }
00124     ERROR_HANDLER_RETURN("Connect",FALSE)
00125 }

BOOL CTCPSocket::Connect ( IP  aDestinationAddress,
unsigned short  usDestinationPort 
) [virtual, inherited]

Definition at line 103 of file TCPSocket.cpp.

00105 {
00106     try
00107     {
00108         return Connect(0,
00109                        aDestinationAddress,
00110                        usDestinationPort);
00111     }
00112     ERROR_HANDLER_RETURN("Connect",FALSE)
00113 }

BOOL CTCPSocket::Connect ( unsigned short  usSourcePort,
const std::string &  rDestinationAddress,
unsigned short  usDestinationPort 
) [virtual, inherited]

Definition at line 196 of file TCPSocket.cpp.

00199 {
00200     try
00201     {
00202         //Quit if not ok
00203         if (!CheckSocketValid())
00204             return FALSE;
00205 
00206         //Delegate the call
00207         return Connect(usSourcePort,
00208                        StringToLong(rDestinationAddress),
00209                        usDestinationPort);
00210     }
00211     ERROR_HANDLER_RETURN("Connect",FALSE)
00212 }

BOOL CTCPSocket::Connect ( unsigned short  usSourcePort,
IP  aDestinationAddress,
unsigned short  usDestinationPort 
) [virtual, inherited]

Definition at line 127 of file TCPSocket.cpp.

00130 {
00131     try
00132     {
00133         //Quit if not ok
00134         if (!CheckSocketValid())
00135             return FALSE;
00136 
00137         //Set async notification
00138         int iResult;
00139         
00140         //Create the address
00141         sockaddr_in aSrc;
00142     
00143         //Set to 0
00144         memset(&aSrc,
00145                0,
00146                sizeof(aSrc));
00147         aSrc.sin_family=AF_INET;
00148         aSrc.sin_addr.s_addr=aDestinationAddress;
00149         aSrc.sin_port=htons(usDestinationPort);
00150 
00151         //Connect
00152         iResult=connect(GetHandle(),
00153                         (sockaddr*)&aSrc,
00154                         sizeof(aSrc));
00155 
00156         //Did we have a blocked error
00157         BOOL bBlocked;
00158         bBlocked=FALSE;
00159 
00160         //Check the result
00161         if (iResult==GetErrorCode())
00162         {
00163             //Check is it blocking error so we can ignore
00164             if (WSAGetLastError()!=WSAEWOULDBLOCK)
00165                 SetLastError("Connect");
00166             else
00167             {
00168                 //Indicate it's blocked error
00169                 bBlocked=TRUE;
00170                 iResult=!GetErrorCode();
00171             }
00172         }
00173         else
00174             //Report the error
00175             SetLastError("Connect");
00176         
00177         if (iResult!=GetErrorCode())
00178         {
00179             //Check if we are a sync socket
00180             if (!IsAsyncClass())
00181                 SetConnectionStatus(TRUE);
00182 
00183             //Save where we are connected
00184             SetConnectedTo(aSrc);
00185         }
00186 
00187         //Done
00188         if (!bBlocked)
00189             return iResult!=GetErrorCode();
00190         else
00191             return FALSE;
00192     }
00193     ERROR_HANDLER_RETURN("Connect",FALSE)
00194 }

BOOL CTCPSocketAsync::Connect ( unsigned short  usSourcePort,
const std::string &  rDestinationAddress,
unsigned short  usDestinationPort,
BOOL  bDisableAsync = FALSE,
BOOL  bForceErrorEvent = FALSE 
) [virtual, inherited]

Reimplemented in CTCPSocketAsyncSSL.

Definition at line 268 of file TCPSocketAsync.cpp.

00273 {
00274     try
00275     {
00276         //Quit if not ok
00277         if (!CheckSocketValid())
00278             return FALSE;
00279 
00280         //Delegate the call
00281         return Connect(usSourcePort,
00282                        StringToLong(rDestinationAddress),
00283                        usDestinationPort,
00284                        bDisableAsync,
00285                        bForceErrorEvent);
00286     }
00287     ERROR_HANDLER_RETURN("Connect",FALSE)
00288 }

BOOL CTCPSocketAsync::Connect ( unsigned short  usSourcePort,
IP  aDestinationAddress,
unsigned short  usDestinationPort,
BOOL  bDisableAsync = FALSE,
BOOL  bForceErrorEvent = FALSE 
) [virtual, inherited]

Reimplemented in CTCPSocketAsyncSSL.

Definition at line 241 of file TCPSocketAsync.cpp.

00246 {
00247     try
00248     {
00249         //Do we have a linked socket?
00250         if (m_pLinkedSocket)
00251             //Delegate to it
00252             return m_pLinkedSocket->Connect(usSourcePort,
00253                                             aDestinationAddress,
00254                                             usDestinationPort,
00255                                             bDisableAsync,
00256                                             bForceErrorEvent);
00257         else
00258             //Our local call
00259             return LocalConnect(usSourcePort,
00260                                 aDestinationAddress,
00261                                 usDestinationPort,
00262                                 bDisableAsync,
00263                                 bForceErrorEvent);
00264     }
00265     ERROR_HANDLER_RETURN("Connect",FALSE)
00266 }

BOOL CTCPSocketAsync::Connect ( const std::string &  rDestinationAddress,
unsigned short  usDestinationPort,
BOOL  bDisableAsync = FALSE,
BOOL  bForceErrorEvent = FALSE 
) [virtual, inherited]

Reimplemented in CTCPSocketAsyncSSL.

Definition at line 116 of file TCPSocketAsync.cpp.

00120 {
00121     try
00122     {
00123         //Delegate the call
00124         return Connect(0,
00125                        rDestinationAddress,
00126                        usDestinationPort,
00127                        bDisableAsync,
00128                        bForceErrorEvent);
00129     }
00130     ERROR_HANDLER_RETURN("Connect",FALSE)
00131 }

BOOL CTCPSocketAsync::Connect ( IP  aDestinationAddress,
unsigned short  usDestinationPort,
BOOL  bDisableAsync = FALSE,
BOOL  bForceErrorEvent = FALSE 
) [virtual, inherited]

Reimplemented in CTCPSocketAsyncSSL.

Definition at line 99 of file TCPSocketAsync.cpp.

00103 {
00104     try
00105     {
00106         //Delegate the call
00107         return Connect(0,
00108                        aDestinationAddress,
00109                        usDestinationPort,
00110                        bDisableAsync,
00111                        bForceErrorEvent);
00112     }
00113     ERROR_HANDLER_RETURN("Connect",FALSE)
00114 }

BOOL CSocket::Create ( int  iProtocol  )  [inherited]

Definition at line 98 of file Socket.cpp.

00099 {
00100     //Close the socket if open
00101     if (ValidSocket())
00102         Close();
00103 
00104     try
00105     {
00106         //Are we overlapped
00107         if (!m_bOverlapped)
00108         {
00109             //Here we create the raw socket
00110             if (m_bRaw || iProtocol==IPPROTO_ICMP)
00111                 m_aSocket=socket(AF_INET,
00112                                       SOCK_RAW,
00113                                       iProtocol);
00114             else
00115                 if (iProtocol==IPPROTO_TCP)
00116                     m_aSocket=socket(AF_INET,
00117                                           SOCK_STREAM,
00118                                           iProtocol);
00119                 else if (iProtocol==IPPROTO_UDP)
00120                     m_aSocket=socket(AF_INET,
00121                                           SOCK_DGRAM,
00122                                           iProtocol);
00123         }
00124         else
00125         {
00126             //Here we create the raw socket
00127             if (m_bRaw || iProtocol==IPPROTO_ICMP)
00128                 m_aSocket=WSASocket(AF_INET,
00129                                          SOCK_RAW,
00130                                          iProtocol,
00131                                          NULL,
00132                                          NULL,
00133                                          WSA_FLAG_OVERLAPPED);
00134             else
00135                 if (iProtocol==IPPROTO_TCP)
00136                     m_aSocket=WSASocket(AF_INET,
00137                                              SOCK_STREAM,
00138                                              iProtocol,
00139                                              NULL,
00140                                              NULL,
00141                                              WSA_FLAG_OVERLAPPED);
00142                 else if (iProtocol==IPPROTO_UDP)
00143                     m_aSocket=WSASocket(AF_INET,
00144                                              SOCK_DGRAM,
00145                                              iProtocol,
00146                                              NULL,
00147                                              NULL,
00148                                              WSA_FLAG_OVERLAPPED);
00149         }
00150 
00151         //Check for socket validity
00152         if (m_aSocket==INVALID_SOCKET)
00153         {
00154             //Error
00155             SetLastError("Create");
00156 
00157             //Done
00158             return FALSE;
00159         }
00160 
00161         if (m_bRaw)
00162         {
00163             //Set that the application will send the IP header
00164             unsigned int iTrue=1;
00165 
00166             if(setsockopt(m_aSocket,
00167                           IPPROTO_IP,
00168                           IP_HDRINCL,
00169                           (char*)&iTrue,
00170                           sizeof(iTrue))==GetErrorCode())
00171             {
00172                 //Check for options error
00173                 SetLastError("Create");
00174 
00175                 //Exit
00176                 return FALSE;
00177             }
00178         }
00179 
00180         //Done
00181         return TRUE;
00182     }
00183     ERROR_HANDLER_RETURN("Create",FALSE)
00184 }

BOOL CTCPSocketAsync::Create (  )  [virtual, inherited]

Reimplemented from CTCPSocket.

Reimplemented in CTCPSocketAsyncSSL.

Definition at line 486 of file TCPSocketAsync.cpp.

00487 {
00488     try
00489     {
00490         if (!CTCPSocket::Create())
00491             return FALSE;
00492         else
00493         {
00494             //Reset events type
00495             m_bCloseEventsOnly=FALSE;
00496 
00497             //New async settings
00498             SocketCreated();
00499 
00500             //Add to list
00501             AddSocketToList();
00502 
00503             //Done
00504             return TRUE;
00505         }
00506     }
00507     ERROR_HANDLER_RETURN("Create",FALSE)
00508 }

void CAsyncSocket::DeleteSocketFromThread ( DWORD  dwTimeToWait  )  [virtual, inherited]

Definition at line 1100 of file AsyncSocket.cpp.

01101 {
01102     try
01103     {
01104         if (!dwTimeToWait)
01105             DeleteSocketFromThread();
01106         else
01107         {
01108             //We are closing
01109             SocketClosing();
01110 
01111             //Are we valid ?
01112             //And do we have a window
01113             if (!m_bList)
01114                 OnSocketDelete();
01115             else
01116             {
01117                 //Create a timer
01118                 m_aDeleteTimerID=GetThreadManager()->RegisterTimeout(dwTimeToWait,
01119                                                                      DeleteTimerProc,
01120                                                                      (LPVOID)this,
01121                                                                      TRUE,
01122                                                                      GetWindowHandle(),
01123                                                                      &m_aDeleteTimerID);
01124 
01125                 //Do we have the timer ?
01126                 if (!m_aDeleteTimerID.iTimerID)
01127                 {
01128                     //Report it
01129                     ReportError("DeleteSocketFromThread","Failed to create timeout!");
01130 
01131                     //Run regular delete
01132                     DeleteSocketFromThread();
01133                 }
01134             }
01135         }
01136     }
01137     ERROR_HANDLER("OnSocketDelete")
01138 }

void CAsyncSocket::DeleteSocketFromThread (  )  [virtual, inherited]

Definition at line 1080 of file AsyncSocket.cpp.

01081 {
01082     try
01083     {
01084         //We are closing
01085         SocketClosing();
01086 
01087         //Are we valid ?
01088         //And do we have a window
01089         if (!m_bList)
01090             OnSocketDelete();
01091         else
01092             PostMessage(GetWindowHandle(),
01093                         WM_SOCKET_DELETE,
01094                         (WPARAM)GetAsyncHandle(),
01095                         0);
01096     }
01097     ERROR_HANDLER("OnSocketDelete")
01098 }

void CAsyncSocket::DeleteSocketFromThreadWait (  )  [virtual, inherited]

Definition at line 1140 of file AsyncSocket.cpp.

01141 {
01142     try
01143     {
01144         //We are closing
01145         SocketClosing();
01146 
01147         //Are we valid ?
01148         //And do we have a window
01149         if (!m_bList)
01150             OnSocketDelete();
01151         else
01152         {
01153             //Create the event
01154             CGenericEvent* pEvent;
01155             pEvent=COSManager::CreateEvent();
01156 
01157             //Post the message
01158             PostMessage(GetWindowHandle(),
01159                         WM_SOCKET_DELETE,
01160                         (WPARAM)GetAsyncHandle(),
01161                         (LPARAM)pEvent);
01162 
01163             //Wait for the event
01164             if (pEvent->Wait(15000))
01165                 //Report it
01166                 ReportStaticError(CAsyncSocket_Class,"DeleteSocketFromThreadWait","Timeout waiting for event!");
01167             else
01168                 delete pEvent;
01169         }
01170     }
01171     ERROR_HANDLER("OnSocketDelete")
01172 }

SOCKET CTCPSocketAsync::Detach (  )  [virtual, inherited]

Reimplemented from CSocket.

Definition at line 881 of file TCPSocketAsync.cpp.

00882 {
00883     //Remove it from the async socket
00884     RemoveSocketFromList();
00885 
00886     //Delegate
00887     return CTCPSocket::Detach();
00888 }

void CAsyncSocket::DetachedSocketThread (  )  [inherited]

Definition at line 165 of file AsyncSocket.cpp.

00166 {
00167     try
00168     {
00169         //Create a new socket imp
00170         CSocketThreadManagerImp* pClone;
00171         pClone=CloneThreadManager(1);
00172 
00173         //Do we have it?
00174         if (!pClone)
00175             //Report it
00176             ReportError("DetachedSocketThread","Failed to create detach manager, will resume as normal!");
00177         else
00178         {
00179             //Set it as local
00180             if (!SetLocalThreadManager(pClone))
00181                 ReportError("DetachedSocketThread","Failed to set manager!");
00182             else
00183                 //Set we are detahced
00184                 m_bDetached=TRUE;
00185         }
00186     }
00187     ERROR_HANDLER("DetachedSocketThread")
00188 }

BOOL CAsyncSocket::DisableAsync (  )  [inherited]

Definition at line 426 of file AsyncSocket.cpp.

00427 {
00428     try
00429     {
00430         //Quit if not ok
00431         if (!CheckAsyncSocketValid())
00432             return FALSE;
00433 
00434         //Set event to read / write / close / oob
00435         int iResult;
00436 
00437         iResult=WSAAsyncSelect(GetAsyncHandle(),
00438                                GetWindowHandle(),
00439                                0,
00440                                0);
00441         if (iResult)
00442         {
00443             //Report it
00444             SetLastError("DisableAsync");
00445 
00446             //Exit
00447             return FALSE;
00448         }
00449         
00450         return TRUE;
00451     }
00452     ERROR_HANDLER_RETURN("DisableAsync",FALSE)
00453 }

void CAsyncSocket::DisableBlockingSend (  )  [inherited]

Definition at line 1343 of file AsyncSocket.cpp.

01344 {
01345     m_bBlockSend=FALSE;
01346 }

void CAsyncSocket::DisableEvents ( unsigned char  ucEvents  )  [inherited]

Definition at line 1205 of file AsyncSocket.cpp.

01206 {
01207     try
01208     {
01209         //Save the events
01210         m_ucEvents=ucEvents;
01211     }
01212     ERROR_HANDLER("DisableEvents")
01213 }

std::string CErrorHandler::ErrorCodeToString ( DWORD  dwErrorCode  )  [static, inherited]

Definition at line 251 of file ErrorHandler.cpp.

00252 {
00253     try
00254     {
00255         //Try to look it in the errors
00256         if (!CErrorsRepository::GetInstance().GetErrorsMap().empty())
00257         {
00258             //Search
00259             CErrorsRepository::ErrorMap::const_iterator aIterator;
00260             aIterator=CErrorsRepository::GetInstance().GetErrorsMap().find(dwErrorCode);
00261 
00262             //Do we have it
00263             if (aIterator!=CErrorsRepository::GetInstance().GetErrorsMap().end())
00264                 return aIterator->second;
00265         }
00266 
00267         //Get the error string
00268         LPVOID lpMsgBuf;
00269         FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | 
00270                       FORMAT_MESSAGE_FROM_SYSTEM | 
00271                       FORMAT_MESSAGE_IGNORE_INSERTS,
00272                       NULL,
00273                       dwErrorCode,
00274                       MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
00275                       (LPTSTR) &lpMsgBuf,
00276                       0,
00277                       NULL);
00278 
00279         //Save it
00280         std::string sMessage;
00281 
00282         //Do we have the message?
00283         if (lpMsgBuf)
00284         {
00285             //Save it
00286             sMessage=(char*)lpMsgBuf;
00287             
00288             //Release the buffer
00289             LocalFree(lpMsgBuf);
00290         }
00291         else
00292             //Failed to find
00293             sMessage="No error description found!";
00294 
00295         //Done
00296         return sMessage;
00297     }
00298     catch (...)
00299     {
00300         return "Unknown";
00301     }
00302 }

void CAsyncSocket::ForceReceiveEvent (  )  [inherited]

Definition at line 1063 of file AsyncSocket.cpp.

01064 {
01065     try
01066     {
01067         //Are we valid ?
01068         //And do we have a window
01069         if (!m_bList)
01070             OnSocketDelete();
01071         else
01072             PostMessage(GetWindowHandle(),
01073                         WM_SOCKET_FORCED,
01074                         (WPARAM)GetAsyncHandle(),
01075                         0);
01076     }
01077     ERROR_HANDLER("ForceReceiveEvent")
01078 }

std::string CErrorHandler::FormatData ( const std::string &  rClass,
const std::string &  rMethod,
const std::string &  rMsgOrError,
bool  bError = true 
) [static, inherited]

Definition at line 145 of file ErrorHandler.cpp.

00149 {
00150     //Our message
00151     std::string sMsg;
00152 
00153     //Is it an error?
00154     if (bError)
00155         sMsg="*** Error *** ";
00156     else
00157         sMsg="###  Msg  ### ";
00158 
00159     //Add the data now
00160     sMsg+="in "+rClass;
00161     sMsg+="::"+rMethod;
00162     sMsg+=" - " + rMsgOrError;
00163 
00164     //Done
00165     return sMsg;
00166 }

void CAsyncSocket::FreezeThread (  )  [inherited]

Definition at line 512 of file AsyncSocket.cpp.

00513 {
00514     m_bFreeze=TRUE;
00515 }

SOCKET CTCPSocketAsync::GetAsyncHandle (  )  const [protected, virtual, inherited]

Implements CAsyncSocket.

Definition at line 481 of file TCPSocketAsync.cpp.

00482 {
00483     return GetHandle();
00484 }

IP CTCPSocketAsync::GetBindAddress (  )  const [virtual, inherited]

Reimplemented from CSocket.

Definition at line 826 of file TCPSocketAsync.cpp.

00827 {
00828     if (m_pLinkedSocket)
00829         return m_pLinkedSocket->GetBindAddress();
00830     else
00831         return LocalGetBindAddress();
00832 }

unsigned short CTCPSocketAsync::GetBindPort (  )  const [virtual, inherited]

Reimplemented from CSocket.

Definition at line 834 of file TCPSocketAsync.cpp.

00835 {
00836     if (m_pLinkedSocket)
00837         return m_pLinkedSocket->GetBindPort();
00838     else
00839         return LocalGetBindPort();
00840 }

CBlockedBuffer * CAsyncSocket::GetBlockedBuffer (  )  const [protected, inherited]

Definition at line 700 of file AsyncSocket.cpp.

00701 {
00702     return m_pBlockedBuffer;
00703 }

const std::string & CErrorHandler::GetClassName (  )  const [protected, inherited]

Reimplemented in CSocketThreadManager.

Definition at line 617 of file ErrorHandler.cpp.

00618 {
00619     return m_sClassName;
00620 }

unsigned long CTCPSocketAsync::GetConnectionTimeout (  )  const [inherited]

Definition at line 701 of file TCPSocketAsync.cpp.

00702 {
00703     return m_ulTimeout;
00704 }

std::string CErrorHandler::GetCurrentDateTime (  )  [static, inherited]

Definition at line 622 of file ErrorHandler.cpp.

00623 {
00624     try
00625     {
00626         //Our string
00627         std::string sDate;
00628 
00629         //Our tmp buf
00630         char cTmp[128];
00631 
00632         //Get date
00633         _strdate(cTmp);
00634         sDate=cTmp;
00635         sDate+=' ';
00636 
00637         //Get time
00638         _strtime(cTmp);
00639         sDate+=cTmp;
00640 
00641         //Done
00642         return sDate;
00643     }
00644     ERROR_HANDLER_STATIC_RETURN(CErrorHandler_Class,"GetCurrentDateTime","")
00645 }

int CSocketBase::GetErrorCode (  )  [static, inherited]

Definition at line 368 of file SocketBase.cpp.

00369 {
00370     return SOCKET_ERROR;
00371 }

CGenericCriticalSection * CSocketBase::GetGlobalCriticalSection (  )  [static, inherited]

Definition at line 363 of file SocketBase.cpp.

00364 {
00365     return m_pCSection;
00366 }

SOCKET CSocket::GetHandle (  )  const [inherited]

Definition at line 369 of file Socket.cpp.

00370 {
00371     return m_aSocket;
00372 }

int CSocketBase::GetLastError (  )  const [inherited]

Definition at line 141 of file SocketBase.cpp.

00142 {
00143     return m_iLastError;
00144 }

unsigned long CSocketBase::GetNumberOfThreads (  )  [static, inherited]

Definition at line 334 of file SocketBase.cpp.

00335 {
00336     return m_ulNumberOfThreads;
00337 }

CTCPSocketAsync::CTCPSocketOverider * CTCPSocketAsync::GetOverider (  )  const [inherited]

Definition at line 816 of file TCPSocketAsync.cpp.

00817 {
00818     return m_pOverider;
00819 }

long CSocket::GetPeerAddress (  )  const [inherited]

Definition at line 677 of file Socket.cpp.

00678 {
00679     //Get the address we are connected to
00680     return m_aConnectedTo.sin_addr.S_un.S_addr;
00681 }

unsigned short CSocket::GetPeerPort (  )  const [inherited]

Definition at line 716 of file Socket.cpp.

00717 {
00718     return htons(m_aConnectedTo.sin_port);
00719 }

unsigned char CSocket::GetProtocol (  )  const [inherited]

Definition at line 855 of file Socket.cpp.

00856 {
00857     return m_ucProtocol;
00858 }

CErrorHandler * CErrorHandler::GetSecondaryLog (  )  [static, inherited]

Definition at line 658 of file ErrorHandler.cpp.

00659 {
00660     //Do we have log
00661     if (!m_pSecondLevelLog)
00662         //Create it
00663         m_pSecondLevelLog=new CErrorHandler;
00664 
00665     //Return it
00666     return m_pSecondLevelLog;
00667 }

int CAsyncSocket::GetSocketID (  )  const [protected, inherited]

Definition at line 246 of file AsyncSocket.cpp.

00247 {
00248     return m_iSocketID;
00249 }

CSocketThreadManagerImp * CAsyncSocket::GetSocketThreadManager (  )  [static, protected, inherited]

Definition at line 711 of file AsyncSocket.cpp.

00712 {
00713     return m_pThreadManager;
00714 }

IP CSocket::GetSourceAddress (  )  const [protected, inherited]

Definition at line 850 of file Socket.cpp.

00851 {
00852     return m_ulSourceAddress;
00853 }

int CSocketBase::GetSystemLastError (  )  [static, inherited]

Definition at line 358 of file SocketBase.cpp.

00359 {
00360     return WSAGetLastError();
00361 }

CErrorHandler * CErrorHandler::GetThirdLog (  )  [static, inherited]

Definition at line 669 of file ErrorHandler.cpp.

00670 {
00671     //Do we have log
00672     if (!m_pThirdLevelLog)
00673         //Create it
00674         m_pThirdLevelLog=new CErrorHandler;
00675 
00676     //Return it
00677     return m_pThirdLevelLog;
00678 }

CSocketThreadManagerImp * CAsyncSocket::GetThreadManager (  )  const [inherited]

Definition at line 393 of file AsyncSocket.cpp.

00394 {
00395     if (!m_pLocalThreadManager)
00396         return m_pThreadManager;
00397     else
00398         return m_pLocalThreadManager;
00399 }

unsigned char CSocket::GetTTL (  )  const [protected, inherited]

Definition at line 845 of file Socket.cpp.

00846 {
00847     return m_ucTTL;
00848 }

HWND CAsyncSocket::GetWindowHandle (  )  const [protected, inherited]

Definition at line 256 of file AsyncSocket.cpp.

00257 {
00258     //Check if we are multithreaded ?
00259     return m_hLocalWindowHandle;
00260 }

BOOL CAsyncSocket::HasSystemTimer (  )  const [protected, inherited]

Definition at line 1044 of file AsyncSocket.cpp.

01045 {
01046     return m_aTimerID.iTimerID!=0;
01047 }

BOOL CAsyncSocket::HasTimeout (  )  const [inherited]

Definition at line 1215 of file AsyncSocket.cpp.

01216 {
01217     return m_bTimeout;
01218 }

void CAsyncSocket::Initialize (  )  [static, inherited]

Definition at line 361 of file AsyncSocket.cpp.

00362 {
00363     try
00364     {
00365         //Initialize all data
00366         if (!m_bInitialized && 
00367             CSocketBase::IsInitialized())
00368         {
00369             //Create the CS
00370             m_pCSection=COSManager::CreateCriticalSection();
00371 
00372             //Create handlers
00373             if (!SetHandlers())
00374             {
00375                 //Report it
00376                 ReportStaticError(CAsyncSocket_Class,"CAsyncSocket","Failed to init handlers!");
00377 
00378                 //Exit
00379                 return;
00380             }
00381 
00382             //Create a new socket to do the shutdown
00383             CAsyncShutdown* pShutdown;
00384             pShutdown=new CAsyncShutdown;
00385 
00386             //The class registers itself
00387             m_bInitialized=TRUE;
00388         }
00389     }
00390     ERROR_HANDLER_STATIC(CAsyncSocket_Class,"Initialize")
00391 }

void CSocket::InitializeIP (  )  [protected, virtual, inherited]

Definition at line 476 of file Socket.cpp.

00477 {
00478     try
00479     {
00480         //Invalid the socket
00481         m_aSocket=INVALID_SOCKET;
00482 
00483         //More invalids
00484         m_ulSourceAddress=0;
00485 
00486         //Some defaults
00487         m_ucTTL=64;
00488 
00489         //We are not overlapped
00490         m_bOverlapped=FALSE;
00491 
00492         //Not connected
00493         memset(&m_aConnectedTo,
00494                0,
00495                sizeof(m_aConnectedTo));
00496     }
00497     ERROR_HANDLER("InitializeIP")
00498 }

BOOL CSocketBase::InitializeSockets ( BOOL  bMultiThreaded = TRUE,
unsigned long  ulNumberOfThreads = 10 
) [static, inherited]

Definition at line 146 of file SocketBase.cpp.

00148 {
00149     //To avoid double initialize
00150     if (m_bInitialized)
00151     {
00152         //Report it
00153         ReportStaticError(CSocketBase_Class,"InitializeSockets","Already initialized!");
00154 
00155         //Exit
00156         return TRUE;
00157     }
00158 
00159     //Check that the number of threads are OK?
00160     if (ulNumberOfThreads>CLibConfig::GetInstance().GetMaxThreads())
00161     {
00162         //Report it
00163         ReportStaticError(CSocketBase_Class,"InitializeSockets","Too many threads!");
00164 
00165         //Exit
00166         return FALSE;
00167     }
00168 
00169     //Do we have threads at all
00170     if (bMultiThreaded &&
00171         !ulNumberOfThreads)
00172     {
00173         //Report it
00174         ReportStaticError(CSocketBase_Class,"InitializeSockets","Didn't receive any threads!");
00175 
00176         //Exit
00177         return FALSE;
00178     }
00179 
00180     try
00181     {
00182         //Initialize the sockets
00183         WORD wVersionRequested;
00184         wVersionRequested=MAKEWORD(2,2);
00185  
00186         //Try to initialize
00187         WSADATA wsaData;
00188         int iErr;
00189         iErr=WSAStartup(wVersionRequested, 
00190                         &wsaData);
00191 
00192         //Did we succeed?
00193         if (iErr!=0)
00194             /* Tell the user that we could not find a usable */
00195             /* WinSock DLL.                                  */
00196             return FALSE;
00197  
00198         /* Confirm that the WinSock DLL supports 2.2.*/
00199         /* Note that if the DLL supports versions greater    */
00200         /* than 2.2 in addition to 2.2, it will still return */
00201         /* 2.2 in wVersion since that is the version we      */
00202         /* requested.                                        */
00203  
00204         if (LOBYTE(wsaData.wVersion)!=2 || 
00205             HIBYTE(wsaData.wVersion)!=2)
00206         {
00207             /* Tell the user that we could not find a usable */
00208             /* WinSock DLL.                                  */
00209             WSACleanup();
00210 
00211             //Exit
00212             return FALSE;
00213         }
00214 
00215         //Save the threading information
00216         m_bMultiThreaded=bMultiThreaded;
00217         m_ulNumberOfThreads=ulNumberOfThreads;
00218 
00219         //Create the critical section
00220         m_pCSection=COSManager::CreateCriticalSection();
00221         m_pCSectionDNS=COSManager::CreateCriticalSection();
00222 
00223         //And we are initialized
00224         m_bInitialized=TRUE;
00225 
00226         return TRUE;
00227     }
00228     ERROR_HANDLER_STATIC_RETURN(CSocketBase_Class,"InitializeSockets",FALSE)
00229 }

int CAsyncSocket::InternalWSAAsyncSelect ( unsigned int  wMsg,
long  lEvent 
) [protected, inherited]

Definition at line 538 of file AsyncSocket.cpp.

00540 {
00541     try
00542     {
00543         //Cache the values
00544         m_iMsg=wMsg;
00545         m_lEvent=lEvent;
00546 
00547         //Message pairs
00548         typedef struct _MsgPair
00549         {
00550             unsigned int    uiMsg;
00551             AsyncEvents     aEvents;
00552         } MsgPair;
00553 
00554         //Our max events
00555         static const int iMaxEvents=4;
00556 
00557         //Our events data
00558         static const MsgPair aMsgPair[iMaxEvents]={{FD_READ,aeReceive},
00559                                                    {FD_WRITE,aeSend},
00560                                                    {FD_OOB,aeOOB},
00561                                                    {FD_CLOSE,aeClose}};
00562 
00563         //Check if the messages are allowed
00564         for (int iCounter=0;
00565              iCounter<iMaxEvents;
00566              ++iCounter)
00567             if ((m_lEvent & aMsgPair[iCounter].uiMsg) &&
00568                 (m_ucEvents & ((unsigned char)aMsgPair[iCounter].aEvents)))
00569                 //Remove it
00570                 m_lEvent^=aMsgPair[iCounter].uiMsg;
00571 
00572         if (m_bBlocking)
00573             return 0;
00574         else
00575             //And call the async select
00576             return WSAAsyncSelect(GetAsyncHandle(),
00577                                   GetWindowHandle(),
00578                                   wMsg,
00579                                   lEvent);
00580     }
00581     ERROR_HANDLER_RETURN("InternalWSAAsyncSelect",GetErrorCode())
00582 }

BOOL CTCPSocketAsync::IsAsyncClass (  )  const [protected, virtual, inherited]

Reimplemented from CTCPSocket.

Definition at line 535 of file TCPSocketAsync.cpp.

00536 {
00537     try
00538     {
00539         //Check if we are blocking
00540         if (IsBlocking() || 
00541             m_bDisabledConnect)
00542             return FALSE;
00543         else
00544             //Not blocking
00545             return TRUE;
00546     }
00547     ERROR_HANDLER_RETURN("IsAsyncClass",FALSE)
00548 }

BOOL CAsyncSocket::IsBlocking (  )  const [protected, inherited]

Definition at line 676 of file AsyncSocket.cpp.

00677 {
00678     return m_bBlocking;
00679 }

BOOL CAsyncSocket::IsBlockSend (  )  const [protected, inherited]

Definition at line 1311 of file AsyncSocket.cpp.

01312 {
01313     return m_bBlockSend;
01314 }

BOOL CAsyncSocket::IsClosing (  )  const [inherited]

Definition at line 1200 of file AsyncSocket.cpp.

01201 {
01202     return m_bClosing;
01203 }

BOOL CTCPSocket::IsConnected (  )  const [inherited]

Definition at line 399 of file TCPSocket.cpp.

00400 {
00401     return m_bConnected;
00402 }

BOOL CSocket::IsCreated (  )  const [inherited]

Definition at line 813 of file Socket.cpp.

00814 {
00815     return ValidSocket();
00816 }

BOOL CAsyncSocket::IsDeleting (  )  const [inherited]

Definition at line 1348 of file AsyncSocket.cpp.

01349 {
01350     return m_bDeleting;
01351 }

BOOL CSocketBase::IsInitialized (  )  [static, inherited]

Definition at line 339 of file SocketBase.cpp.

00340 {
00341     return m_bInitialized;
00342 }

BOOL CAsyncSocket::IsInThread (  )  const [protected, inherited]

Definition at line 1316 of file AsyncSocket.cpp.

01317 {
01318     try
01319     {
01320         //Do we have the thread?
01321         if (m_pThread)
01322             return m_pThread->IsInThread();
01323         else
01324             return FALSE;
01325     }
01326     ERROR_HANDLER_RETURN("IsInThread",FALSE)
01327 }

BOOL CSocketBase::IsMultiThreaded (  )  [static, inherited]

Definition at line 329 of file SocketBase.cpp.

00330 {
00331     return m_bMultiThreaded;
00332 }

BOOL CSocket::IsRaw (  )  const [inherited]

Definition at line 471 of file Socket.cpp.

00472 {
00473     return m_bRaw;
00474 }

BOOL CAsyncSocket::IsTimeout (  )  const [protected, inherited]

Definition at line 356 of file AsyncSocket.cpp.

00357 {
00358     return m_bTimeout;
00359 }

BOOL CAsyncSocket::KillSystemTimer (  )  [protected, inherited]

Definition at line 993 of file AsyncSocket.cpp.

00994 {
00995     try
00996     {
00997         //Only if we have one
00998         if (!m_aTimerID.iTimerID)
00999             return TRUE;
01000 
01001         return GetThreadManager()->RemoveTimeout(m_aTimerID);
01002     }
01003     ERROR_HANDLER_RETURN("KillSystemTimer",FALSE)
01004 }

BOOL CAsyncSocket::KillTimer (  )  [inherited]

Definition at line 303 of file AsyncSocket.cpp.

00304 {
00305     try
00306     {
00307         //Get the handle
00308         HWND hWindowHandle;
00309         hWindowHandle=GetWindowHandle();
00310 
00311         if (!hWindowHandle || 
00312             !m_bTimeout)
00313             return FALSE;
00314 
00315         //No timer in any case
00316         m_bTimeout=FALSE;
00317 
00318         //Try to kill the timer
00319         BOOL bResult;
00320         bResult=::KillTimer(hWindowHandle,
00321                             GetAsyncHandle());
00322 
00323         if (!bResult)
00324             //Fire an error
00325             ReportError("KillTimer");
00326 
00327         return bResult;
00328     }
00329     ERROR_HANDLER_RETURN("KillTimer",FALSE)
00330 }

BOOL CTCPSocketAsync::Listen ( unsigned long  ulBackLog = 5  )  [virtual, inherited]

Reimplemented from CTCPSocket.

Definition at line 769 of file TCPSocketAsync.cpp.

00770 {
00771     try
00772     {
00773         //Do we have a linked socket?
00774         if (m_pLinkedSocket)
00775             //Delegate the call
00776             return m_pLinkedSocket->Listen(ulBackLog);
00777         else
00778             return LocalListen(ulBackLog);
00779     }
00780     ERROR_HANDLER_RETURN("Listen",FALSE)
00781 }

BOOL CTCPSocketAsync::LocalAccept ( CTCPSocket pNewSocket  )  [protected, inherited]

Definition at line 872 of file TCPSocketAsync.cpp.

00873 {
00874     try
00875     {
00876         return CTCPSocket::Accept(pNewSocket);
00877     }
00878     ERROR_HANDLER_RETURN("LocalAccept",FALSE)
00879 }

BOOL CTCPSocketAsync::LocalBind ( IP  aSourceAddress,
unsigned short  usPort 
) [protected, inherited]

Definition at line 800 of file TCPSocketAsync.cpp.

00802 {
00803     try
00804     {
00805         return CTCPSocket::Bind(aSourceAddress,
00806                                 usPort);
00807     }
00808     ERROR_HANDLER_RETURN("LocalBind",FALSE)
00809 }

BOOL CTCPSocketAsync::LocalConnect ( unsigned short  usSourcePort,
IP  aDestinationAddress,
unsigned short  usDestinationPort,
BOOL  bDisableAsync,
BOOL  bForceErrorEvent 
) [protected, inherited]

Definition at line 133 of file TCPSocketAsync.cpp.

00138 {
00139     try
00140     {
00141         //Quit if not ok
00142         if (!CheckSocketValid())
00143             return FALSE;
00144 
00145         //Set the async notification
00146         if (!bDisableAsync)
00147         {
00148             int iResult;
00149             iResult=InternalWSAAsyncSelect(WM_SOCKET_CONNECT,
00150                                            FD_CONNECT);
00151 
00152             if (iResult)
00153             {
00154                 //Get the error code
00155                 int iErrorCode;
00156                 iErrorCode=GetSystemLastError();
00157 
00158                 //Report it
00159                 SetLastError("Connect");
00160 
00161                 //Do we need to call event?
00162                 if (bForceErrorEvent)
00163                     SocketConnected(iErrorCode);
00164 
00165                 //Exit
00166                 return FALSE;
00167             }
00168 
00169             //Set our timeout
00170             if (m_ulTimeout &&
00171                 !IsBlocking())
00172                 if (!SetSystemTimeout(m_ulTimeout))
00173                 {
00174                     //Report it
00175                     ReportError("LocalConnect","Failed to set timer!");
00176 
00177                     //Do we need to call event?
00178                     if (bForceErrorEvent)
00179                         SocketConnected(GetErrorCode());
00180 
00181                     //Exit
00182                     return FALSE;
00183                 }
00184         }
00185         //Set to non blocking!
00186         else if (!Block())
00187             return FALSE;
00188 
00189         //Set the flag
00190         m_bDisabledConnect=bDisableAsync;
00191 
00192         //Call the original connect
00193         BOOL bResult;
00194         bResult=CTCPSocket::Connect(usSourcePort,
00195                                     aDestinationAddress,
00196                                     usDestinationPort);
00197 
00198         //Reset the flag
00199         m_bDisabledConnect=FALSE;
00200 
00201         if (bResult)
00202         {
00203             //Call event, but only if in async
00204             if (!bDisableAsync &&
00205                 !IsBlocking())
00206                 //Call user, will add socket automatically
00207                 return SocketConnected(0);
00208             else
00209                 //Set as async
00210                 return SetAsync();
00211         }
00212         else if (GetSystemLastError()!=WSAEWOULDBLOCK ||
00213                  bDisableAsync ||
00214                  IsBlocking())
00215         {
00216             if (m_ulTimeout)
00217                 //Kill the timer
00218                 KillSystemTimer();
00219 
00220             //Get the error code
00221             int iErrorCode;
00222             iErrorCode=GetSystemLastError();
00223 
00224             //Report it
00225             SetLastError("Connect");
00226 
00227             //Do we need to call event?
00228             if (bForceErrorEvent &&
00229                 !bDisableAsync)
00230                 SocketConnected(iErrorCode);
00231 
00232             //Exit
00233             return FALSE;
00234         }
00235         else
00236             return TRUE;
00237     }
00238     ERROR_HANDLER_RETURN("LocalConnect",FALSE)
00239 }

IP CTCPSocketAsync::LocalGetBindAddress (  )  const [protected, inherited]

Definition at line 842 of file TCPSocketAsync.cpp.

00843 {
00844     try
00845     {
00846         return CTCPSocket::GetBindAddress();
00847     }
00848     ERROR_HANDLER_RETURN("LocalGetBindAddress",0)
00849 }

unsigned short CTCPSocketAsync::LocalGetBindPort (  )  const [protected, inherited]

Definition at line 851 of file TCPSocketAsync.cpp.

00852 {
00853     try
00854     {
00855         return CTCPSocket::GetBindPort();
00856     }
00857     ERROR_HANDLER_RETURN("LocalGetBindPort",0)
00858 }

BOOL CTCPSocketAsync::LocalListen ( unsigned long  ulBackLog  )  [protected, inherited]

Definition at line 290 of file TCPSocketAsync.cpp.

00291 {
00292     try
00293     {
00294         //Quit if not ok
00295         if (!CheckSocketValid())
00296             return FALSE;
00297 
00298         //Try to switch the mode
00299         int iResult;
00300         iResult=InternalWSAAsyncSelect(WM_SOCKET_ACCEPT,
00301                                        FD_ACCEPT);
00302 
00303         //Is it OK
00304         if (iResult)
00305         {
00306             //Report it
00307             SetLastError("LocalListen");
00308 
00309             //Exit
00310             return FALSE;
00311         }
00312 
00313         //Delegate the call
00314         return CTCPSocket::Listen(ulBackLog);
00315     }
00316     ERROR_HANDLER_RETURN("LocalListen",FALSE)
00317 }

BOOL CTCPSocketAsync::LocalSocketAccept ( int  iErrorCode,
BOOL  bNoEvent 
) [protected, inherited]

Definition at line 422 of file TCPSocketAsync.cpp.

00424 {
00425     try
00426     {
00427         //Delegate call
00428         return CAsyncSocket::SocketAccept(iErrorCode,
00429                                           bNoEvent);
00430     }
00431     ERROR_HANDLER_RETURN("LocalSocketAccept",FALSE)
00432 }

BOOL CTCPSocketAsync::LocalSocketClose ( int  iErrorCode,
BOOL  bNoEvent 
) [protected, inherited]

Definition at line 453 of file TCPSocketAsync.cpp.

00455 {
00456     try
00457     {
00458         //We are not connected
00459         SetConnectionStatus(FALSE);
00460 
00461         //Call father
00462         return CAsyncSocket::SocketClosed(iErrorCode,
00463                                           bNoEvent);
00464     }
00465     ERROR_HANDLER_RETURN("LocalSocketClose",FALSE)
00466 }

BOOL CTCPSocketAsync::LocalSocketConnect ( int  iErrorCode,
BOOL  bNoEvent 
) [protected, inherited]

Definition at line 351 of file TCPSocketAsync.cpp.

00353 {
00354     try
00355     {
00356         if (m_ulTimeout)
00357             //Kill the timer
00358             KillSystemTimer();
00359 
00360         //Did we got an error
00361         if (!iErrorCode)
00362             //Set the connection status
00363             SetConnectionStatus(TRUE);
00364         
00365         //Call father
00366         return CAsyncSocket::SocketConnected(iErrorCode,
00367                                              bNoEvent);
00368     }
00369     ERROR_HANDLER_RETURN("LocalSocketConnect",FALSE)
00370 }

BOOL CTCPSocketAsync::LocalSocketReceive ( int  iErrorCode,
BOOL  bNoEvent 
) [protected, inherited]

Definition at line 391 of file TCPSocketAsync.cpp.

00393 {
00394     try
00395     {
00396         //Delegate call
00397         return CAsyncSocket::SocketReceive(iErrorCode,
00398                                            bNoEvent);
00399     }
00400     ERROR_HANDLER_RETURN("LocalSocketReceivet",FALSE)
00401 }

std::string CSocketBase::LongToStdString ( unsigned long  ulAddr  )  [static, inherited]

Definition at line 291 of file SocketBase.cpp.

00292 {
00293     try
00294     {
00295         //First create the address
00296         in_addr addr;
00297 
00298         //Assign it
00299         addr.S_un.S_addr=ulAddr;
00300 
00301         //Enter the critical section
00302         CCriticalAutoRelease aRelease(m_pCSection);
00303 
00304         //Return the value
00305         return inet_ntoa(addr);
00306     }
00307     ERROR_HANDLER_STATIC_RETURN(CSocketBase_Class,"LongToStdString","0.0.0.0")
00308 }

char FAR * CSocketBase::LongToString ( unsigned long  ulAddr  )  [static, inherited]

Definition at line 310 of file SocketBase.cpp.

00311 {
00312     try
00313     {
00314         //First create the address
00315         in_addr addr;
00316 
00317         //Assign it
00318         addr.S_un.S_addr=ulAddr;
00319 
00320         //Enter the critical section
00321         CCriticalAutoRelease aRelease(m_pCSection);
00322 
00323         //Return the value
00324         return inet_ntoa(addr);
00325     }
00326     ERROR_HANDLER_STATIC_RETURN(CSocketBase_Class,"LongToString",NULL)
00327 }

void CSocketBase::NotifyShutdown (  )  [protected, virtual, inherited]

Definition at line 273 of file SocketBase.cpp.

00274 {
00275 }

virtual BOOL CAsyncSocket::OnSocketAccept ( int  iErrorCode  )  [protected, pure virtual, inherited]

virtual BOOL CAsyncSocket::OnSocketClose ( int  iErrorCode  )  [protected, pure virtual, inherited]

Implemented in CSocketPoolSocket.

virtual BOOL CAsyncSocket::OnSocketConnect ( int  iErrorCode  )  [protected, pure virtual, inherited]

Implemented in CSocketPoolSocket, and CUDPSocketAsync.

void CAsyncSocket::OnSocketDelete ( CGenericEvent pEvent = NULL  )  [protected, virtual, inherited]

Definition at line 1049 of file AsyncSocket.cpp.

01050 {
01051     try
01052     {
01053         //Delete ourselves
01054         delete this;
01055 
01056         //Do we have an event?
01057         if (pEvent)
01058             pEvent->Set();
01059     }
01060     ERROR_HANDLER_STATIC(CAsyncSocket_Class,"OnSocketDelete")
01061 }

virtual BOOL CAsyncSocket::OnSocketOOB ( int  iErrorCode  )  [protected, pure virtual, inherited]

virtual BOOL CAsyncSocket::OnSocketReceive ( int  iErrorCode  )  [protected, pure virtual, inherited]

virtual BOOL CAsyncSocket::OnSocketTimeout (  )  [protected, pure virtual, inherited]

virtual BOOL CAsyncSocket::OnSocketWrite ( int  iErrorCode  )  [protected, pure virtual, inherited]

CTCPSocketAsync::operator const CTCPSocketAsync::CTCPSocketOverider * (  )  const [inherited]

Definition at line 821 of file TCPSocketAsync.cpp.

00822 {
00823     return m_pOverider;
00824 }

bool CSocket::operator< ( const CSocket rSocket  )  const [inherited]

Definition at line 892 of file Socket.cpp.

00893 {
00894     return m_aSocket<rSocket.m_aSocket;
00895 }

bool CSocket::operator== ( const CSocket rSocket  )  const [inherited]

Definition at line 887 of file Socket.cpp.

00888 {
00889     return m_aSocket==rSocket.m_aSocket;
00890 }

int CTCPSocketAsync::Peek ( char *  pBuffer,
unsigned long  ulBufferLength 
) [virtual, inherited]

Reimplemented from CSocket.

Reimplemented in CTCPSocketAsyncSSL.

Definition at line 731 of file TCPSocketAsync.cpp.

00733 {
00734     try
00735     {
00736         //Try to receive
00737         int iResult;
00738         if ((iResult=CTCPSocket::Peek(pBuffer,
00739                                          ulBufferLength))>=0)
00740             return iResult;
00741         //Check is it an error
00742         else if (GetSystemLastError()==WSAEWOULDBLOCK)
00743             return 0;
00744         else
00745             return GetErrorCode();
00746     }
00747     ERROR_HANDLER_RETURN("Peek",GetErrorCode())
00748 }

BOOL CAsyncSocket::ReAsync (  )  [virtual, inherited]

Definition at line 598 of file AsyncSocket.cpp.

00599 {
00600     if (!m_bBlocking)
00601         return TRUE;
00602 
00603     try
00604     {
00605         //Quit if not ok
00606         if (!CheckAsyncSocketValid())
00607             return FALSE;
00608 
00609         //First disable the events
00610         int iResult;
00611         iResult=WSAAsyncSelect(GetAsyncHandle(),
00612                                GetWindowHandle(),
00613                                m_iMsg,
00614                                m_lEvent);
00615 
00616         if (iResult)
00617         {
00618             //Report it
00619             SetLastError("ReAsync");
00620 
00621             //Exit
00622             return FALSE;
00623         }
00624 
00625         //Set to async
00626         m_bBlocking=FALSE;
00627 
00628         //And quit
00629         return TRUE;
00630     }
00631     ERROR_HANDLER_RETURN("ReAsync",FALSE)
00632 }

BOOL CAsyncSocket::ReBlock (  )  [virtual, inherited]

Definition at line 517 of file AsyncSocket.cpp.

00518 {
00519     if (m_bBlocking)
00520         return TRUE;
00521 
00522     try
00523     {
00524         //Quit if not ok
00525         if (!CheckAsyncSocketValid())
00526             return FALSE;
00527 
00528         if (Block())
00529             //Set to reblock
00530             m_bBlocking=TRUE;
00531 
00532         //And quit
00533         return TRUE;
00534     }
00535     ERROR_HANDLER_RETURN("ReBlock",FALSE)
00536 }

int CTCPSocketAsync::Receive ( char *  pBuffer,
unsigned long  ulBufferLength 
) [virtual, inherited]

Reimplemented from CSocket.

Reimplemented in CTCPSocketAsyncSSL.

Definition at line 712 of file TCPSocketAsync.cpp.

00714 {
00715     try
00716     {
00717         //Try to receive
00718         int iResult;
00719         if ((iResult=CTCPSocket::Receive(pBuffer,
00720                                          ulBufferLength))>=0)
00721             return iResult;
00722         //Check is it an error
00723         else if (GetSystemLastError()==WSAEWOULDBLOCK)
00724             return 0;
00725         else
00726             return GetErrorCode();
00727     }
00728     ERROR_HANDLER_RETURN("Receive",GetErrorCode())
00729 }

int CSocket::ReceiveFrom ( char *  pBuffer,
unsigned long  ulBufferLength,
IP rIP,
unsigned short &  rSourcePort 
) [protected, virtual, inherited]

Definition at line 514 of file Socket.cpp.

00518 {
00519     try
00520     {
00521         if (!ValidSocket() ||
00522             !pBuffer ||
00523             !ulBufferLength)
00524             return GetErrorCode();
00525 
00526         //Receive data
00527         int iResult;
00528 
00529         //Receive
00530         if (m_ucProtocol!=IPPROTO_TCP)
00531         {
00532             //Get the remote address
00533             sockaddr saConnected;
00534 
00535             int iTmp;
00536             iTmp=sizeof(saConnected);
00537 
00538             //Accept it
00539             iResult=recvfrom(GetHandle(),
00540                              pBuffer,
00541                              ulBufferLength,
00542                              NULL,
00543                              &saConnected,
00544                              &iTmp);
00545 
00546             //If OK set it
00547             if (iResult!=GetErrorCode())
00548             {
00549                 //Address
00550                 rIP=((sockaddr_in*)&saConnected)->sin_addr.S_un.S_addr;
00551 
00552                 //Port
00553                 rSourcePort=htons(((sockaddr_in*)&saConnected)->sin_port);
00554 
00555                 //Done
00556                 return iResult;
00557             }
00558             else
00559             {
00560                 //Error
00561                 SetLastError("Receive");
00562 
00563                 //Reset the data
00564                 rIP=0;
00565                 rSourcePort=0;
00566 
00567                 //Done
00568                 return iResult;
00569             }
00570         }
00571         else
00572         {
00573             //Report it
00574             ReportError("Receive","Can't run on TCP socket!");
00575 
00576             //Exit
00577             return GetErrorCode();
00578         }
00579     }
00580     ERROR_HANDLER_RETURN("Receive",GetErrorCode())
00581 }

int CTCPSocketAsyncMsg::ReceiveMsg ( char *  pData,
int  iSize,
int &  iMoreMessages 
) [virtual]

Definition at line 176 of file TCPSocketAsyncMsg.cpp.

00179 {
00180     return InternalReceiveMsg(pData,
00181                               iSize,
00182                               iMoreMessages,
00183                               false);
00184 }

void CErrorHandler::RegisterError ( DWORD  dwErrorCode,
const std::string &  rDescription 
) [static, inherited]

Definition at line 647 of file ErrorHandler.cpp.

00649 {
00650     try
00651     {
00652         //Add the error
00653         CErrorsRepository::GetInstance().GetErrorsMap().insert(CErrorsRepository::ErrorMap::value_type(dwErrorCode,rDescription));
00654     }
00655     ERROR_HANDLER_STATIC(CErrorHandler_Class,"RegisterError")
00656 }

void CSocketBase::RegisterShutdown ( CSocketBase pBase  )  [protected, inherited]

Definition at line 277 of file SocketBase.cpp.

00278 {
00279     try
00280     {
00281         //Check if we already have a class
00282         if (m_pShutdownClass)
00283             delete m_pShutdownClass;
00284 
00285         //Take it
00286         m_pShutdownClass=pBase;
00287     }
00288     ERROR_HANDLER("RegisterShutdown")
00289 }

CSocketThreadManagerImp::TimerID CAsyncSocket::RegisterTimeout ( int  iMS,
CSocketThreadManagerImp::LPTimeoutProc  pProc,
LPVOID  pData,
BOOL  bClearTimeout = FALSE,
CSocketThreadManagerImp::TimerID pTimer = NULL 
) [inherited]

Definition at line 1220 of file AsyncSocket.cpp.

01225 {
01226     //Delegate the call
01227     return GetThreadManager()->RegisterTimeout(iMS,
01228                                                pProc,
01229                                                pData,
01230                                                bClearTimeout,
01231                                                GetWindowHandle(),
01232                                                pTimer);
01233 }

void CAsyncSocket::RemoveSocketFromList (  )  [protected, inherited]

Definition at line 262 of file AsyncSocket.cpp.

00263 {
00264     try
00265     {
00266         if (m_bList)
00267         {
00268             //Remove from thread manager
00269             GetThreadManager()->RemoveSocket(this);
00270 
00271             //Not in list
00272             m_bList=FALSE;
00273 
00274             //Deallocate the handle
00275             DeAllocateHandle();
00276         }
00277     }
00278     ERROR_HANDLER("RemoveSocketFromList")
00279 }

void CErrorHandler::ReportError ( const std::string &  rMethod,
const std::string &  rMessage,
int  iErrorCode 
) const [protected, virtual, inherited]

Definition at line 304 of file ErrorHandler.cpp.

00307 {
00308     if (!GetLog())
00309         return;
00310 
00311     try
00312     {
00313         //Convert the error code
00314         char aTmp[11];
00315         sprintf(aTmp,"%d",iErrorCode);
00316 
00317         //Get the string for it
00318         std::string sError;
00319         sError=rMessage;
00320         sError+=", and Socket error: ";
00321         sError+=aTmp;
00322         sError+=", ";
00323         sError+=ErrorCodeToString(iErrorCode);
00324 
00325         //Report to the log
00326         WriteError(m_sClassName,
00327                    rMethod,
00328                    sError);
00329     }
00330     ERROR_UNKNOWN("ReportError")
00331 }

void CErrorHandler::ReportError ( const std::string &  rMethod,
int  iErrorCode 
) const [protected, virtual, inherited]

Definition at line 333 of file ErrorHandler.cpp.

00335 {
00336     if (!GetLog())
00337         return;
00338 
00339     try
00340     {
00341         //Convert the error code
00342         char aTmp[11];
00343         sprintf(aTmp,"%d",iErrorCode);
00344 
00345         //Get the string for it
00346         std::string sError;
00347         sError="Socket error: ";
00348         sError+=aTmp;
00349         sError+=", ";
00350         sError+=ErrorCodeToString(iErrorCode);
00351 
00352         //Report to the log
00353         WriteError(m_sClassName,
00354                    rMethod,
00355                    sError);
00356     }
00357     ERROR_UNKNOWN("ReportError")
00358 }

void CErrorHandler::ReportError ( const std::string &  rMethod,
const std::string &  rMessage,
const std::string &  rAdditionalData 
) const [protected, virtual, inherited]

Definition at line 461 of file ErrorHandler.cpp.

00464 {
00465     if (!GetLog())
00466         return;
00467 
00468     try
00469     {
00470         //Create the new message
00471         std::string sNewMessage(rMessage);
00472         sNewMessage+=", Additional data: ";
00473         sNewMessage+=rAdditionalData;
00474 
00475         //Report to the log
00476         WriteError(m_sClassName,
00477                    rMethod,
00478                    sNewMessage);
00479     }
00480     ERROR_UNKNOWN("ReportError")
00481 }

void CErrorHandler::ReportError ( const std::string &  rMethod,
const std::string &  rMessage,
DWORD  dwAdditionalData 
) const [protected, virtual, inherited]

Definition at line 483 of file ErrorHandler.cpp.

00486 {
00487     if (!GetLog())
00488         return;
00489 
00490     try
00491     {
00492         //Convert the number
00493         char aTmp[11];
00494         ltoa(dwAdditionalData,aTmp,10);
00495 
00496         //Create the new message
00497         std::string sNewMessage(rMessage);
00498         sNewMessage+=", Additional data: ";
00499         sNewMessage+=aTmp;
00500 
00501         //Report to the log
00502         WriteError(m_sClassName,
00503                    rMethod,
00504                    sNewMessage);
00505     }
00506     ERROR_UNKNOWN("ReportError")
00507 }

void CErrorHandler::ReportError ( const std::string &  rMethod,
const std::string &  rMessage 
) const [protected, virtual, inherited]

Definition at line 376 of file ErrorHandler.cpp.

00378 {
00379     if (!GetLog())
00380         return;
00381 
00382     try
00383     {
00384         //Report to the log
00385         WriteError(m_sClassName,
00386                    rMethod,
00387                    rMessage);
00388     }
00389     ERROR_UNKNOWN("ReportError")
00390 }

void CErrorHandler::ReportError ( const std::string &  rMethod  )  const [protected, virtual, inherited]

Definition at line 515 of file ErrorHandler.cpp.

00516 {
00517     if (!GetLog())
00518         return;
00519 
00520     try
00521     {
00522         //Get the last error
00523         DWORD dwLastError;
00524         dwLastError=GetLastError();
00525 
00526         //Report the error
00527         WriteError(m_sClassName,
00528                    rMethod,
00529                    ErrorCodeToString(dwLastError));
00530     }
00531     ERROR_UNKNOWN("ReportError")
00532 }

void CErrorHandler::ReportErrorOS ( const std::string &  rMethod,
const std::string &  rMessage 
) const [protected, virtual, inherited]

Definition at line 427 of file ErrorHandler.cpp.

00429 {
00430     if (!GetLog())
00431         return;
00432 
00433     try
00434     {
00435         //Get the last error
00436         DWORD dwLastError;
00437         dwLastError=GetLastError();
00438 
00439         //Format the message
00440         std::string sMessage;
00441         sMessage=rMessage;
00442         sMessage+=", with error code: ";
00443 
00444         //Convert the error code
00445         char aTmp[11];
00446         itoa(dwLastError,aTmp,10);
00447 
00448         //Add it again
00449         sMessage+=aTmp;
00450         sMessage+=" ";
00451         sMessage+=ErrorCodeToString(dwLastError);
00452 
00453         //Report to the log
00454         WriteError(m_sClassName,
00455                    rMethod,
00456                    sMessage);
00457     }
00458     ERROR_UNKNOWN("ReportErrorOS")
00459 }

void CErrorHandler::ReportStaticError ( const std::string &  rClass,
const std::string &  rMethod,
const std::string &  rMessage,
DWORD  dwAdditionalData 
) [static, protected, inherited]

Definition at line 590 of file ErrorHandler.cpp.

00594 {
00595     if (!m_pLog)
00596         return;
00597 
00598     try
00599     {
00600         //Convert the number
00601         char aTmp[11];
00602         ltoa(dwAdditionalData,aTmp,10);
00603 
00604         //Create the new message
00605         std::string sNewMessage(rMessage);
00606         sNewMessage+=", Additional data: ";
00607         sNewMessage+=aTmp;
00608 
00609         //Report to the log
00610         WriteStaticError(rClass,
00611                          rMethod,
00612                          sNewMessage);
00613     }
00614     ERROR_UNKNOWN("ReportStaticError")
00615 }

void CErrorHandler::ReportStaticError ( const std::string &  rClass,
const std::string &  rMethod,
const std::string &  rMessage 
) [static, protected, inherited]

Definition at line 573 of file ErrorHandler.cpp.

00576 {
00577     if (!m_pLog)
00578         return;
00579 
00580     try
00581     {
00582         //Report to the log
00583         WriteStaticError(rClass,
00584                          rMethod,
00585                          rMessage);
00586     }
00587     ERROR_UNKNOWN("ReportStaticError")
00588 }

void CErrorHandler::ReportStaticError ( const std::string &  rClass,
const std::string &  rMethod 
) [static, protected, inherited]

Definition at line 553 of file ErrorHandler.cpp.

00555 {
00556     if (!m_pLog)
00557         return;
00558 
00559     try
00560     {
00561         //Get the last error
00562         DWORD dwLastError;
00563         dwLastError=GetLastError();
00564 
00565         //Report the error
00566         WriteStaticError(rClass,
00567                           rMethod,
00568                           ErrorCodeToString(dwLastError));
00569     }
00570     ERROR_UNKNOWN("ReportStaticError")
00571 }

void CErrorHandler::ReportStaticErrorOS ( const std::string &  rClass,
const std::string &  rMethod,
const std::string &  rMessage 
) [static, protected, inherited]

Definition at line 392 of file ErrorHandler.cpp.

00395 {
00396     if (!m_pLog)
00397         return;
00398 
00399     try
00400     {
00401         //Get the last error
00402         DWORD dwLastError;
00403         dwLastError=GetLastError();
00404 
00405         //Format the message
00406         std::string sMessage;
00407         sMessage=rMessage;
00408         sMessage+=", with error code: ";
00409 
00410         //Convert the error code
00411         char aTmp[11];
00412         itoa(dwLastError,aTmp,10);
00413 
00414         //Add it again
00415         sMessage+=aTmp;
00416         sMessage+=" ";
00417         sMessage+=ErrorCodeToString(dwLastError);
00418         
00419         //Report to the log
00420         WriteStaticError(rClass,
00421                          rMethod,
00422                          sMessage);
00423     }
00424     ERROR_UNKNOWN("ReportStaticError")
00425 }

void CAsyncSocket::ResetEvent (  )  [protected, inherited]

Definition at line 1338 of file AsyncSocket.cpp.

01339 {
01340     m_pSendEvent->Reset();
01341 }

unsigned long CSocketBase::ResolveDNS ( const std::string &  rAddress  )  [static, inherited]

Definition at line 431 of file SocketBase.cpp.

00432 {
00433     try
00434     {
00435         //Resolve the DNS
00436         sockaddr_in aAddr;
00437         aAddr=InternalResolveDNS(rAddress.c_str());
00438 
00439         //Check if valid
00440         if (aAddr.sin_addr.S_un.S_addr==0)
00441             //Error
00442             return 0;
00443         else
00444             return aAddr.sin_addr.S_un.S_addr;
00445     }
00446     ERROR_HANDLER_STATIC_RETURN(CSocketBase_Class,"ResolveDNS",0)
00447 }

int CSocket::Send ( const std::string &  rDestinationAddress,
const char *  pBuffer,
unsigned long  ulBufferLength,
unsigned short  usDestinationPort = 0 
) [virtual, inherited]

Definition at line 245 of file Socket.cpp.

00249 {
00250     try
00251     {
00252         //Quit if not ok
00253         if (!CheckSocketValid())
00254             return GetErrorCode();
00255 
00256         return Send(inet_addr(rDestinationAddress.c_str()),
00257                     pBuffer,
00258                     ulBufferLength,
00259                     usDestinationPort);
00260     }
00261     ERROR_HANDLER_RETURN("Send",GetErrorCode())
00262 }

int CSocket::Send ( IP  aDestinationAddress,
const char *  pBuffer,
unsigned long  ulBufferLength,
unsigned short  usDestinationPort = 0 
) [virtual, inherited]

Definition at line 191 of file Socket.cpp.

00195 {
00196     try
00197     {
00198         //Quit if not ok
00199         if (!CheckSocketValid())
00200             return GetErrorCode();
00201 
00202         //Is it a valid size
00203         if (ulBufferLength &&
00204             !pBuffer)
00205             return GetErrorCode();
00206 
00207         //Define the target address
00208         sockaddr_in aTargetAddress;
00209         memset(&aTargetAddress,
00210                0,
00211                sizeof(aTargetAddress));
00212 
00213         aTargetAddress.sin_family=AF_INET;
00214         aTargetAddress.sin_addr.s_addr=aDestinationAddress;
00215         aTargetAddress.sin_port=htons(usDestinationPort);
00216 
00217         //packet send status ?
00218         int iResult;
00219 
00220         //Set to no error
00221         iResult=!GetErrorCode();
00222 
00223         //Check if we had an error
00224         if (iResult!=GetErrorCode())
00225             //Use regular send !!!
00226             iResult=sendto(GetHandle(),
00227                            (const char*)pBuffer,
00228                            ulBufferLength,
00229                            0,
00230                            (sockaddr*)&aTargetAddress,
00231                            sizeof(aTargetAddress));
00232         
00233         //Is all OK?
00234         if (iResult==GetErrorCode() &&
00235             GetSystemLastError()!=WSAEWOULDBLOCK)
00236             //Set the error
00237             SetLastError("Send");
00238         
00239         //Done
00240         return iResult;
00241     }
00242     ERROR_HANDLER_RETURN("Send",GetErrorCode())
00243 }

int CTCPSocketAsync::Send ( const char *  pBuffer,
unsigned long  ulBufferLength 
) [virtual, inherited]

Reimplemented from CTCPSocket.

Reimplemented in CTCPSocketAsyncSSL.

Definition at line 571 of file TCPSocketAsync.cpp.

00573 {
00574     try
00575     {
00576         //Reset the event
00577         ResetEvent();
00578 
00579         //Send the data
00580         int iResult;
00581         iResult=SendNoAdd(pBuffer,
00582                           ulBufferLength);
00583 
00584         //Did we succeed ?
00585         if (iResult==GetErrorCode())
00586             //Is it blocked send ?
00587             if (WSAGetLastError()==WSAEWOULDBLOCK)
00588                 if (GetBlockedBuffer())
00589                 {
00590                     //Add to the buffer, if we have one
00591                     GetBlockedBuffer()->AddRecord(CBlockedBuffer::CBlockedData(pBuffer,
00592                                                                                ulBufferLength));
00593 
00594                     //We have not error
00595                     iResult=0;
00596                 }
00597                 else if (IsBlockSend())
00598                     //Are we in the same thread?
00599                     if (!IsInThread())
00600                         if (WaitForBlockEvent())
00601                         {
00602                             //Set the error
00603 							::SetLastError(WSAENOTCONN);
00604 
00605                             //Exit
00606                             return GetErrorCode();
00607                         }
00608                         else
00609                             //Retry to send
00610                             return Send(pBuffer,
00611                                         ulBufferLength);
00612                     else
00613                     {
00614                         //We'll have to do a loop
00615                         Sleep(10);
00616 
00617                         //Try again
00618                         if (SendNoAdd(pBuffer,
00619                                       ulBufferLength)==GetErrorCode())
00620                             //Which error
00621                             if (WSAGetLastError()==WSAEWOULDBLOCK)
00622                                 return 0;
00623                             else
00624                                 return GetErrorCode();
00625                     }
00626                 //Blocking error (not really an error)
00627                 else
00628                     return 0;
00629             else
00630                 //Set the error code
00631                 SetLastError("Send");
00632 
00633         //Done
00634         return iResult;
00635     }
00636     ERROR_HANDLER_RETURN("Send",GetErrorCode())
00637 }

BOOL CTCPSocketAsync::SendBlockedBuffer ( const CBlockedBuffer::CBlockedData rData  )  [protected, virtual, inherited]

Reimplemented from CAsyncSocket.

Definition at line 560 of file TCPSocketAsync.cpp.

00561 {
00562     try
00563     {
00564         //Try to send it
00565         return SendNoAdd(rData.GetData(),
00566                          rData.GetDataSize())!=GetErrorCode();
00567     }
00568     ERROR_HANDLER_RETURN("SendBlockedBuffer",FALSE)
00569 }

int CTCPSocketAsyncMsg::SendMsg ( const char *  pData,
int  iSize,
CGenericEvent pStopEvent 
) [virtual]

Definition at line 222 of file TCPSocketAsyncMsg.cpp.

00225 {
00226     try
00227     {
00228         //Create the buffer
00229         char* pTmp;
00230         pTmp=new char[iSize+sizeof(DWORD)];
00231 
00232         //Protect it
00233         CArray_ptr<char> pProtection(pTmp);
00234 
00235         //Copy the size
00236         memcpy(pTmp,
00237                &iSize,
00238                sizeof(DWORD));
00239 
00240         //Copy the data
00241         memcpy(pTmp+sizeof(DWORD),
00242                pData,
00243                iSize);
00244 
00245         //Our new size
00246         DWORD dwSize(iSize);
00247         dwSize+=4;
00248 
00249         //Try to send it
00250         //Our position
00251         DWORD dwPos;
00252         dwPos=0;
00253 
00254         while (1)
00255         {
00256             //How much we need to send
00257             DWORD dwSend;
00258             if (dwPos+SEND_CHUNK>dwSize)
00259                 dwSend=dwSize-dwPos;
00260             else
00261                 dwSend=SEND_CHUNK;
00262 
00263             //Try to send
00264             int iResult;
00265             iResult=Send(pTmp+dwPos,
00266                          dwSend);
00267 
00268             //Check send size
00269             if (iResult>0)
00270                 if (iResult!=dwSend)
00271                     return -2;
00272                 //Check for the event
00273                 else if (!pStopEvent->Wait(0))
00274                     return -3;
00275                 else
00276                 {
00277                     //Advance the pointers
00278                     dwPos+=dwSend;
00279 
00280                     //Do we need to exit?
00281                     if (dwPos==dwSize)
00282                         return dwPos-sizeof(DWORD);
00283                 }
00284             else if (GetLastError()!=WSAEWOULDBLOCK)
00285                 return iResult;
00286             //Sleep and wait for event
00287             else if (!pStopEvent->Wait(1))
00288                 return -3;
00289         }
00290     }
00291     ERROR_HANDLER_RETURN("SendMsg",-1)
00292 }

int CTCPSocketAsyncMsg::SendMsg ( const char *  pData,
int  iSize 
) [virtual]

Definition at line 186 of file TCPSocketAsyncMsg.cpp.

00188 {
00189     try
00190     {
00191         //Create the buffer
00192         char* pTmp;
00193         pTmp=new char[iSize+sizeof(DWORD)];
00194 
00195         //Protect it
00196         CArray_ptr<char> pProtection(pTmp);
00197 
00198         //Copy the size
00199         memcpy(pTmp,
00200                &iSize,
00201                sizeof(DWORD));
00202 
00203         //Copy the data
00204         memcpy(pTmp+sizeof(DWORD),
00205                pData,
00206                iSize);
00207 
00208         //Try to send it
00209         int iResult;
00210         iResult=Send(pTmp,
00211                      iSize+sizeof(DWORD));
00212 
00213         //Check send size
00214         if (iResult==iSize+sizeof(DWORD))
00215             return iSize;
00216         else
00217             return iResult;
00218     }
00219     ERROR_HANDLER_RETURN("SendMsg",-1)
00220 }

int CTCPSocketAsync::SendNoAdd ( const char *  pBuffer,
unsigned long  ulBufferLength 
) [protected, virtual, inherited]

Definition at line 639 of file TCPSocketAsync.cpp.

00641 {
00642     try
00643     {
00644         //Quit if not ok
00645         if (!CheckSocketValid())
00646             return FALSE;
00647 
00648         //Send the data
00649         int iResult;
00650 
00651         //And send it
00652         iResult=send(GetHandle(),
00653                      pBuffer,
00654                      ulBufferLength,
00655                      NULL);
00656 
00657         //And exit
00658         return iResult;
00659     }
00660     ERROR_HANDLER_RETURN("SendNoAdd",GetErrorCode())
00661 }

void CTCPSocket::SetAcceptance ( CTCPSocket pNewSocket,
SOCKET  aSocket,
sockaddr_in  aAddress 
) const [protected, inherited]

Definition at line 347 of file TCPSocket.cpp.

00350 {
00351     //Call before accept routing
00352     pNewSocket->BeforeAccept();
00353 
00354     //Set the socket data
00355     pNewSocket->SetConnectedTo(aAddress);
00356     pNewSocket->AssignSocket(aSocket);
00357     pNewSocket->SetConnectionStatus(TRUE);
00358     pNewSocket->Accepted();
00359 }

BOOL CTCPSocketAsync::SetAsync (  )  [protected, virtual, inherited]

Implements CAsyncSocket.

Definition at line 319 of file TCPSocketAsync.cpp.

00320 {
00321     try
00322     {
00323         //Quit if not ok
00324         if (!CheckSocketValid())
00325             return FALSE;
00326 
00327         //Set event to read / write / close / oob
00328         int iResult;
00329         iResult=InternalWSAAsyncSelect(WM_SOCKET_GENERAL,
00330                                        FD_WRITE | 
00331                                        FD_READ | 
00332                                        FD_CLOSE | 
00333                                        FD_OOB);
00334 
00335         //What happend
00336         if (iResult)
00337         {
00338             //Report it
00339             SetLastError("SetAsync");
00340 
00341             //Exit
00342             return FALSE;
00343         }
00344         
00345         //Done
00346         return TRUE;
00347     }
00348     ERROR_HANDLER_RETURN("SetAsync",FALSE)
00349 }

BOOL CSocket::SetBroadcast ( BOOL  bBroadcast  )  [inherited]

Definition at line 818 of file Socket.cpp.

00819 {
00820     try
00821     {
00822         //Quit if not ok
00823         if (!CheckSocketValid())
00824             return FALSE;
00825 
00826         //Set broadcast option
00827         if(setsockopt(GetHandle(),
00828                       SOL_SOCKET,
00829                       SO_BROADCAST,
00830                       (char*)&bBroadcast,
00831                       sizeof(bBroadcast))==GetErrorCode())
00832         {
00833             //Check for options error
00834             SetLastError("SetBroadcast");
00835 
00836             //Exit
00837             return FALSE;
00838         }   
00839 
00840         return TRUE;
00841     }
00842     ERROR_HANDLER_RETURN("SetBroadcast",FALSE)
00843 }

void CAsyncSocket::SetCleanTimeout ( DWORD  dwTimeout  )  [static, inherited]

Definition at line 1358 of file AsyncSocket.cpp.

01359 {
01360     //Change the thread manager
01361     if (m_pThreadManager)
01362         m_pThreadManager->SetCleanTimeout(dwTimeout);
01363 }

void CSocket::SetConnectedTo ( const sockaddr_in &  rAddress  )  [protected, inherited]

Definition at line 897 of file Socket.cpp.

00898 {
00899     m_aConnectedTo=rAddress;
00900 }

void CTCPSocket::SetConnectionStatus ( BOOL  bConnected  )  [protected, inherited]

Definition at line 394 of file TCPSocket.cpp.

00395 {
00396     m_bConnected=bConnected;
00397 }

BOOL CTCPSocketAsync::SetConnectionTimeout ( unsigned long  ulMS  )  [inherited]

Definition at line 677 of file TCPSocketAsync.cpp.

00678 {
00679     try
00680     {
00681         //Do we have a timeout ?
00682         if (HasSystemTimer())
00683             if (!KillSystemTimer())
00684             {
00685                 //Report it
00686                 ReportError("SetConnectionTimeout","Failed to kill previous timer!");
00687 
00688                 //Exit
00689                 return FALSE;
00690             }
00691 
00692         //Create the timer
00693         m_ulTimeout=ulMS;
00694 
00695         //Done
00696         return TRUE;
00697     }
00698     ERROR_HANDLER_RETURN("SetConnectionTimeout",FALSE)
00699 }

void CAsyncSocket::SetDeleting (  )  [inherited]

Definition at line 1353 of file AsyncSocket.cpp.

01354 {
01355     m_bDeleting=TRUE;
01356 }

void CAsyncSocket::SetInstance ( HINSTANCE  hInst  )  [static, inherited]

Definition at line 251 of file AsyncSocket.cpp.

00252 {
00253     m_hInstance=hInst;
00254 }

void CSocketBase::SetLastError ( const std::string &  rMethod,
int  iErrorCode 
) const [protected, inherited]

Definition at line 124 of file SocketBase.cpp.

00126 {
00127     try
00128     {
00129         //First set the error
00130         m_iLastError=iErrorCode;
00131 
00132         //Check if there is an error
00133         if (m_iLastError)
00134             ReportError(rMethod,
00135                         "Through SetLastError",
00136                         m_iLastError);
00137     }
00138     ERROR_HANDLER("SetLastError")
00139 }

void CSocketBase::SetLastError ( const std::string &  rMethod  )  const [protected, inherited]

Definition at line 104 of file SocketBase.cpp.

00105 {
00106     try
00107     {
00108 #ifdef WIN32
00109         //First set the error
00110         m_iLastError=WSAGetLastError();
00111 #else
00112         m_iLastError=errno();
00113 #endif
00114 
00115         //Check if there is an error
00116         if (m_iLastError)
00117             ReportError(rMethod,
00118                         "Through SetLastError",
00119                         m_iLastError);
00120     }
00121     ERROR_HANDLER("SetLastError")
00122 }

void CTCPSocketAsync::SetLinkedSocket ( CTCPSocketAsync pSocket,
CTCPSocketOverider pOverider 
) [inherited]

Definition at line 750 of file TCPSocketAsync.cpp.

00752 {
00753     try
00754     {
00755         //Do we have an old socket?
00756         if (m_pLinkedSocket)
00757             m_pLinkedSocket->DeleteSocketFromThread();
00758 
00759         //Save it
00760         m_pLinkedSocket=pSocket;
00761         m_pOverider=pOverider;
00762 
00763         //Set the events type
00764         m_bCloseEventsOnly=FALSE;
00765     }
00766     ERROR_HANDLER("SetLinkedSocket")
00767 }

void CErrorHandler::SetLocalLog ( CErrorLog pLog,
bool  bWriteToMain = false 
) [inherited]

Definition at line 543 of file ErrorHandler.cpp.

00545 {
00546     //Save the log
00547     m_pLocalLog=pLog;
00548 
00549     //Save the write to main flag
00550     m_bWriteToMain=bWriteToMain;
00551 }

BOOL CAsyncSocket::SetLocalThreadManager ( CSocketThreadManagerImp pManager  )  [inherited]

Definition at line 1235 of file AsyncSocket.cpp.

01236 {
01237     try
01238     {
01239         //We can do it only if we are not created
01240         if (GetAsyncHandle()!=INVALID_SOCKET)
01241         {
01242             //Report it
01243             ReportError("SetLocalThreadManager","Can't switch after socket is created!");
01244 
01245             //Exit
01246             return FALSE;
01247         }
01248 
01249         //Is it a legal manager
01250         if (!pManager ||
01251             !pManager->IsInitialized())
01252         {
01253             //Report it
01254             ReportError("SetLocalThreadManager","Manager is either null or not initialized!");
01255 
01256             //Exit
01257             return FALSE;
01258         }
01259 
01260         //Save the new manager
01261         m_pLocalThreadManager=pManager;
01262 
01263         //Done
01264         return TRUE;
01265     }
01266     ERROR_HANDLER_RETURN("SetLocalThreadManager",FALSE)
01267 }

void CErrorHandler::SetLog ( CErrorLog pLog  )  [static, inherited]

Definition at line 509 of file ErrorHandler.cpp.

00510 {
00511     //Save the new log
00512     m_pLog=pLog;
00513 }

BOOL CTCPSocket::SetNagle ( BOOL  bNagle  )  [inherited]

Definition at line 409 of file TCPSocket.cpp.

00410 {
00411     try
00412     {
00413         //Quit if not ok
00414         if (!CheckSocketValid())
00415             return FALSE;
00416 
00417         //Invert the flag (convert to true bool)
00418         if (bNagle)
00419             bNagle=FALSE;
00420         else
00421             bNagle=TRUE;
00422 
00423         //Try to set the option
00424         if (setsockopt(GetHandle(),
00425                        IPPROTO_TCP,
00426                        TCP_NODELAY,
00427                        (const char*)&bNagle,
00428                        sizeof(bNagle))==GetErrorCode())
00429         {
00430             //Report it
00431             ReportError("SetNagle","Failed to set nagle");
00432 
00433             //Set it
00434             SetLastError("SetNagle");
00435         
00436             //Exit
00437             return FALSE;
00438         }
00439 
00440         //Done
00441         return TRUE;
00442     }
00443     ERROR_HANDLER_RETURN("SetNagle",FALSE)
00444 }

void CErrorHandler::SetName ( const std::string &  rName  )  const [protected, inherited]

Definition at line 139 of file ErrorHandler.cpp.

00140 {
00141     //Save the class name
00142     m_sClassName=rName;
00143 }

void CSocket::SetProtocol ( unsigned char  iProtocol  )  [inherited]

Definition at line 186 of file Socket.cpp.

00187 {
00188     m_ucProtocol=ucProtocol;
00189 }

BOOL CSocket::SetReceiveTimeout ( unsigned long  ulMS  )  [inherited]

Definition at line 860 of file Socket.cpp.

00861 {
00862     try
00863     {
00864         //Quit if not ok
00865         if (!CheckSocketValid())
00866             return FALSE;
00867 
00868         //Set it
00869         if(setsockopt(GetHandle(),
00870                       SOL_SOCKET,
00871                       SO_RCVTIMEO,
00872                       (char*)&ulMS,
00873                       sizeof(ulMS))==GetErrorCode())
00874         {
00875             //Check for options error
00876             SetLastError("SetReceiveTimeout");
00877 
00878             //Exit
00879             return FALSE;
00880         }
00881         else
00882             return TRUE;
00883     }
00884     ERROR_HANDLER_RETURN("SetReceiveTimeout",FALSE)
00885 }

void CSocket::SetSourceAddress ( const std::string &  rSourceAddress  )  [virtual, inherited]

Definition at line 440 of file Socket.cpp.

00441 {
00442     try
00443     {
00444         //Set the source address, in case we want to spoof it
00445         if (rSourceAddress.empty())
00446             m_ulSourceAddress=0;
00447         else
00448             m_ulSourceAddress=inet_addr(rSourceAddress.c_str());
00449     }
00450     ERROR_HANDLER("SetSourceAddress")
00451 }

void CSocket::SetSourceAddress ( IP  aSourceAddress  )  [virtual, inherited]

Definition at line 435 of file Socket.cpp.

00436 {
00437     m_ulSourceAddress=aSourceAddress;
00438 }

BOOL CAsyncSocket::SetSystemTimeout ( int  iMS  )  [protected, inherited]

Definition at line 956 of file AsyncSocket.cpp.

00957 {
00958     try
00959     {
00960         //Do we have a timeout
00961         if (m_aTimerID.iTimerID)
00962         {
00963             //Report it
00964             ReportError("SetSystemTimeout","Please kill previous timer!");
00965 
00966             //Exit
00967             return FALSE;
00968         }
00969 
00970         //Create the timer
00971         m_aTimerID=GetThreadManager()->RegisterTimeout(iMS,
00972                                                        SystemTimerProc,
00973                                                        this,
00974                                                        TRUE,
00975                                                        GetWindowHandle(),
00976                                                        &m_aTimerID);
00977 
00978         //Do we have it
00979         if (!m_aTimerID.iTimerID)
00980         {
00981             //Report it
00982             ReportError("SetSystemTimeout","Failed creating the timer!");
00983 
00984             //Exit
00985             return FALSE;
00986         }
00987         else
00988             return TRUE;
00989     }
00990     ERROR_HANDLER_RETURN("SetSystemTimeout",FALSE)
00991 }

BOOL CAsyncSocket::SetTimeout ( int  iMs  )  [inherited]

Definition at line 281 of file AsyncSocket.cpp.

00282 {
00283     try
00284     {
00285         //Get the window handle
00286         HWND hWindowHandle;
00287         hWindowHandle=GetWindowHandle();
00288 
00289         if (!hWindowHandle)
00290             return FALSE;
00291 
00292         //Set the timer
00293         m_bTimeout=SetTimer(hWindowHandle,
00294                             GetAsyncHandle(),
00295                             iMs,
00296                             NULL);
00297 
00298         return m_bTimeout;
00299     }
00300     ERROR_HANDLER_RETURN("SetTimeout",FALSE)
00301 }

void CSocket::SetTTL ( unsigned char  ucTTL  )  [inherited]

Definition at line 453 of file Socket.cpp.

00454 {
00455     try
00456     {
00457         //Quit if not ok
00458         if (!CheckSocketValid())
00459             return;
00460 
00461         if(setsockopt(GetHandle(),
00462                       IPPROTO_IP,
00463                       IP_TTL,
00464                       (const char*)&ucTTL,
00465                       sizeof(ucTTL)))
00466             SetLastError("SetTTL");
00467     }
00468     ERROR_HANDLER("SetTTL")
00469 }

void CAsyncSocket::Shutdown (  )  [static, inherited]

Definition at line 332 of file AsyncSocket.cpp.

00333 {
00334     try
00335     {
00336         //Only if initialized
00337         if (!m_bInitialized)
00338             return;
00339 
00340         //Indicate we're shutting down
00341         m_bShuttingDown=TRUE;
00342 
00343         //Delete the thread manager
00344         if (m_pThreadManager)
00345         {
00346             delete m_pThreadManager;
00347             m_pThreadManager=NULL;
00348         }
00349 
00350         //Not initialized anymore
00351         m_bInitialized=FALSE;
00352     }
00353     ERROR_HANDLER_STATIC(CAsyncSocket_Class,"Shutdown")
00354 }

BOOL CSocket::Shutdown ( SocketShutdown  eHow  )  [inherited]

Definition at line 683 of file Socket.cpp.

00684 {
00685     if (!CheckSocketValid())
00686         return FALSE;
00687 
00688     try
00689     {
00690         int iHow;
00691 
00692         //Convert the how to a real flag
00693         if (eHow==ssReceive)
00694             iHow=SD_RECEIVE;
00695         else if (eHow==ssSend)
00696             iHow=SD_SEND;
00697         else
00698             iHow=SD_BOTH;
00699 
00700         //Do it
00701         if (shutdown(GetHandle(),iHow))
00702         {
00703             //Report it
00704             SetLastError("Shutdown");
00705 
00706             //Exit
00707             return FALSE;
00708         }
00709 
00710         //Done
00711         return TRUE;
00712     }
00713     ERROR_HANDLER_RETURN("Shutdown",FALSE)
00714 }

BOOL CSocketBase::ShutdownSockets (  )  [static, inherited]

Definition at line 231 of file SocketBase.cpp.

00232 {
00233     //Only if initialized
00234     if (!m_bInitialized)
00235         return TRUE;
00236 
00237     try
00238     {
00239         //Delete the CS
00240         delete m_pCSection;
00241         m_pCSection=NULL;
00242 
00243         //Delete the DNS CS
00244         delete m_pCSectionDNS;
00245         m_pCSectionDNS=NULL;
00246 
00247         //Clear the DNS map
00248         m_aDNSMap.clear();
00249 
00250         //Notify shutdown class
00251         if (m_pShutdownClass)
00252         {
00253             //Notify we are shuting down
00254             m_pShutdownClass->NotifyShutdown();
00255 
00256             //Delete it
00257             delete m_pShutdownClass;
00258             m_pShutdownClass=NULL;
00259         }
00260 
00261         //Not initialized anymore
00262         m_bInitialized=FALSE;
00263 
00264         if (WSACleanup()==GetErrorCode())
00265             return FALSE;
00266 
00267         //Done
00268         return TRUE;
00269     }
00270     ERROR_HANDLER_STATIC_RETURN(CSocketBase_Class,"ShutdownSockets",FALSE)
00271 }

void CAsyncSocket::SimpleMessageMap ( LPMapProc  pProc,
BOOL  bStopWhenTRUE,
DWORD  dwSleep 
) [static, inherited]

Definition at line 866 of file AsyncSocket.cpp.

00869 {
00870     try
00871     {
00872         //Check if we have the proc
00873         if (!pProc)
00874         {
00875             //Report it
00876             ReportStaticError(CAsyncSocket_Class,"SimpleMessageMap","Recieved null proc!");
00877 
00878             //Exit
00879             return;
00880         }
00881 
00882         //If there is no message map, then receive won't work
00883         MSG msg;
00884 
00885         //Set the message map to zeros
00886         memset(&msg,
00887                0,
00888                sizeof(msg));
00889 
00890         //Stop flag
00891         BOOL bStop;
00892         bStop=FALSE;
00893 
00894         //Start the loop
00895         while (!bStop &&
00896                (*pProc)()!=bStopWhenTRUE)
00897         {
00898             while (!(bStop=(*pProc)()==bStopWhenTRUE) &&
00899                    PeekMessage(&msg, 
00900                                NULL, 
00901                                0, 
00902                                0, 
00903                                PM_REMOVE))
00904             {
00905                 TranslateMessage(&msg);
00906                 DispatchMessage(&msg); 
00907             }
00908 
00909             //Do we need to sleep?
00910             if (!bStop)
00911                 //No messages
00912                 Sleep(dwSleep);
00913         }
00914     }
00915     ERROR_HANDLER_STATIC(CAsyncSocket_Class,"SimpleMessageMap")
00916 }

void CAsyncSocket::SimpleMessageMap ( DWORD  dwRunTimeMS  )  [static, inherited]

Definition at line 830 of file AsyncSocket.cpp.

00831 {
00832     try
00833     {
00834         //If there is no message map, then receive won't work
00835         MSG msg;
00836 
00837         //Set the message map to zeros
00838         memset(&msg,
00839                0,
00840                sizeof(msg));
00841 
00842         //Start loop
00843         DWORD dwLoopStart;
00844         dwLoopStart=GetTickCount();
00845 
00846         //Until a key was hit
00847         while (GetTickCount()-dwLoopStart<dwRunTimeMS)
00848         {
00849             while (PeekMessage(&msg, 
00850                                NULL, 
00851                                0, 
00852                                0, 
00853                                PM_REMOVE))
00854             {
00855                 TranslateMessage(&msg);
00856                 DispatchMessage(&msg); 
00857             }
00858 
00859             //Sleep so wont be hanged
00860             Sleep(1);
00861         }
00862     }
00863     ERROR_HANDLER_STATIC(CAsyncSocket_Class,"SimpleMessageMap")
00864 }

void CAsyncSocket::SimpleMessageMap (  )  [static, inherited]

Definition at line 805 of file AsyncSocket.cpp.

00806 {
00807     try
00808     {
00809         //If there is no message map, then receive won't work
00810         MSG msg;
00811 
00812         //Set the message map to zeros
00813         memset(&msg,
00814                0,
00815                sizeof(msg));
00816 
00817         while (GetMessage(&msg,
00818                           NULL,
00819                           0,
00820                           0))
00821         {
00822             //Dispatch the message
00823             TranslateMessage(&msg);
00824             DispatchMessage(&msg);
00825         }
00826     }
00827     ERROR_HANDLER_STATIC(CAsyncSocket_Class,"SimpleMessageMap")
00828 }

char CAsyncSocket::SimpleMessageMapKey ( DWORD  dwSleep  )  [static, inherited]

Definition at line 918 of file AsyncSocket.cpp.

00919 {
00920     try
00921     {
00922         //If there is no message map, then receive won't work
00923         MSG msg;
00924 
00925         //Set the message map to zeros
00926         memset(&msg,
00927                0,
00928                sizeof(msg));
00929 
00930         //Until a key was hit
00931         while (!kbhit())
00932         {
00933             while (!kbhit() &&
00934                    PeekMessage(&msg, 
00935                                NULL, 
00936                                0, 
00937                                0, 
00938                                PM_REMOVE))
00939             {
00940                 TranslateMessage(&msg);
00941                 DispatchMessage(&msg); 
00942             }
00943 
00944             //Do we need to sleep
00945             if (!kbhit())
00946                 //Sleep so wont be hanged
00947                 Sleep(dwSleep);
00948         }
00949         
00950         //Return the char
00951         return getch();
00952     }
00953     ERROR_HANDLER_STATIC_RETURN(CAsyncSocket_Class,"SimpleMessageMapKey",0)
00954 }

BOOL CAsyncSocket::SocketAccept ( int  iErrorCode,
BOOL  bNoEvent = FALSE 
) [protected, virtual, inherited]

Definition at line 758 of file AsyncSocket.cpp.

00760 {
00761     try
00762     {
00763         //Do we need to call event?
00764         if (!bNoEvent)
00765             return OnSocketAccept(iErrorCode);
00766         else
00767             return FALSE;
00768     }
00769     ERROR_HANDLER_RETURN("SocketConnected",FALSE)
00770 }

BOOL CTCPSocketAsync::SocketClosed ( int  iErrorCode,
BOOL  bNoEvent 
) [protected, virtual, inherited]

Reimplemented from CAsyncSocket.

Definition at line 434 of file TCPSocketAsync.cpp.

00436 {
00437     try
00438     {
00439         if (m_pLinkedSocket &&
00440             !m_bCloseEventsOnly)
00441             //Delegate the call
00442             return m_pLinkedSocket->SocketClosed(iErrorCode,
00443                                                  bNoEvent);
00444         else
00445             //Local version
00446             return LocalSocketClose(iErrorCode,
00447                                     bNoEvent);
00448         
00449     }
00450     ERROR_HANDLER_RETURN("SocketClosed",FALSE)
00451 }

void CAsyncSocket::SocketClosing (  )  [protected, inherited]

Definition at line 475 of file AsyncSocket.cpp.

00476 {
00477     try
00478     {
00479         //Are we valid
00480         if (m_bClosing ||
00481             GetAsyncHandle()==INVALID_SOCKET)
00482             return;
00483 
00484         //Indicate we are closing
00485         m_bClosing=TRUE;
00486 
00487         //Signal the event
00488         m_pSendEvent->Set();
00489 
00490         //Do we have a regular timer
00491         if (m_bTimeout)
00492             KillTimer();
00493 
00494         //Do we have a system timer ?
00495         if (m_aTimerID.iTimerID)
00496             KillSystemTimer();
00497 
00498         //Kill all the messages
00499         m_iMsg=0;
00500         m_lEvent=0;
00501 
00502         //Set it
00503         if (WSAAsyncSelect(GetAsyncHandle(),
00504                            GetWindowHandle(),
00505                            0,
00506                            0))
00507             SetLastError("SocketClosing");
00508     }
00509     ERROR_HANDLER("SocketClosing")
00510 }

BOOL CTCPSocketAsync::SocketConnected ( int  iErrorCode,
BOOL  bNoEvent = FALSE 
) [protected, virtual, inherited]

Reimplemented from CAsyncSocket.

Reimplemented in CTCPSocketAsyncSSL.

Definition at line 372 of file TCPSocketAsync.cpp.

00374 {
00375     try
00376     {
00377         //Do we have a linked socket?
00378         if (m_pLinkedSocket &&
00379             !m_bCloseEventsOnly)
00380             //Delegate it
00381             return m_pLinkedSocket->SocketConnected(iErrorCode,
00382                                                     bNoEvent);
00383         else
00384             //Local call
00385             return LocalSocketConnect(iErrorCode,
00386                                       bNoEvent);
00387     }
00388     ERROR_HANDLER_RETURN("SocketConnected",FALSE)
00389 }

void CAsyncSocket::SocketCreated (  )  [protected, virtual, inherited]

Definition at line 1174 of file AsyncSocket.cpp.

01175 {
01176     try
01177     {
01178         //No timer
01179         memset(&m_aTimerID,
01180                0,
01181                sizeof(m_aTimerID));
01182 
01183         //No delete timer
01184         memset(&m_aDeleteTimerID,
01185                0,
01186                sizeof(m_aDeleteTimerID));
01187 
01188         //Set values for new socket
01189         m_iSocketID=0;
01190         m_bBlocking=FALSE;
01191         m_bFreeze=FALSE;
01192         m_lEvent=0;
01193         m_hLocalWindowHandle=0;
01194         m_bList=FALSE;
01195         m_bClosing=FALSE;
01196     }
01197     ERROR_HANDLER("SocketCreated")
01198 }

BOOL CTCPSocketAsync::SocketReceive ( int  iErrorCode,
BOOL  bNoEvent = FALSE 
) [protected, virtual, inherited]

Reimplemented from CAsyncSocket.

Reimplemented in CTCPSocketAsyncSSL.

Definition at line 403 of file TCPSocketAsync.cpp.

00405 {
00406     try
00407     {
00408         //Do we have a linked socket?
00409         if (m_pLinkedSocket &&
00410             !m_bCloseEventsOnly)
00411             //Delegate it
00412             return m_pLinkedSocket->SocketReceive(iErrorCode,
00413                                                     bNoEvent);
00414         else
00415             //Local call
00416             return LocalSocketReceive(iErrorCode,
00417                                       bNoEvent);
00418     }
00419     ERROR_HANDLER_RETURN("SocketConnected",FALSE)
00420 }

BOOL CTCPSocketAsync::SocketWrite ( int  iErrorCode  )  [protected, virtual, inherited]

Reimplemented from CAsyncSocket.

Reimplemented in CTCPSocketAsyncSSL.

Definition at line 663 of file TCPSocketAsync.cpp.

00664 {
00665     try
00666     {
00667         //Only if we have a buffer
00668         if (GetBlockedBuffer())
00669             GetBlockedBuffer()->SendData();
00670 
00671         //Call father
00672         return CAsyncSocket::SocketWrite(iErrorCode);
00673     }
00674     ERROR_HANDLER_RETURN("OnSocketWrite",TRUE)
00675 }

unsigned long CSocketBase::StringToLong ( const std::string &  rAddress  )  [static, inherited]

Definition at line 344 of file SocketBase.cpp.

00345 {
00346     //Try to convert it
00347     unsigned long ulAddress;
00348     ulAddress=inet_addr(rAddress.c_str());
00349 
00350     //Is it valid
00351     if (ulAddress!=INADDR_NONE)
00352         return ulAddress;
00353     else
00354         //Try to resolve it
00355         return ResolveDNS(rAddress);
00356 }

BOOL CSocketBase::ValidAddress ( const std::string &  rAddress  )  [static, inherited]

Definition at line 373 of file SocketBase.cpp.

00374 {
00375     try
00376     {
00377         return inet_addr(rAddress.c_str())!=INADDR_NONE;
00378     }
00379     ERROR_HANDLER_STATIC_RETURN(CSocketBase_Class,"ValidAddress",FALSE)
00380 }

BOOL CSocket::ValidSocket (  )  const [protected, inherited]

Definition at line 264 of file Socket.cpp.

00265 {
00266     return m_aSocket!=INVALID_SOCKET;
00267 }

BOOL CAsyncSocket::WaitForBlockEvent (  )  const [protected, inherited]

Definition at line 1329 of file AsyncSocket.cpp.

01330 {
01331     //Wait for the event
01332     if (m_pSendEvent->Wait(5000))
01333         return TRUE;
01334     else
01335         return IsClosing();
01336 }

void CErrorHandler::WriteError ( const std::string &  rClass,
const std::string &  rMethod,
const std::string &  rError 
) const [inherited]

Definition at line 168 of file ErrorHandler.cpp.

00171 {
00172     //Do we have a log?
00173     if (!GetLog())
00174         return;
00175 
00176     //Format the msg
00177     std::string sError;
00178     sError=FormatData(rClass,
00179                       rMethod,
00180                       rError);
00181 
00182     //Write it
00183     GetLog()->WriteError(sError);
00184 
00185     //Write to main
00186     if (m_bWriteToMain &&
00187         m_pLog)
00188         //Write it
00189         m_pLog->WriteError(sError);
00190 }

void CErrorHandler::WriteMessage ( const std::string &  rMethod,
const std::string &  rMessage 
) const [protected, inherited]

Definition at line 360 of file ErrorHandler.cpp.

00362 {
00363     if (!GetLog())
00364         return;
00365 
00366     try
00367     {
00368         //Report to the log
00369         WriteMessage(m_sClassName,
00370                      rMethod,
00371                      rMessage);
00372     }
00373     ERROR_UNKNOWN("WriteMessage")
00374 }

void CErrorHandler::WriteMessage ( const std::string &  rClass,
const std::string &  rMethod,
const std::string &  rMessage 
) const [inherited]

Definition at line 226 of file ErrorHandler.cpp.

00229 {
00230     //Do we have a log?
00231     if (!GetLog())
00232         return;
00233 
00234     //Format the msg
00235     std::string sMsg;
00236     sMsg=FormatData(rClass,
00237                     rMethod,
00238                     rMessage,
00239                     false);
00240 
00241     //Write it
00242     GetLog()->WriteMessage(sMsg);
00243 
00244     //Write to main
00245     if (m_bWriteToMain &&
00246         m_pLog)
00247         //Write it
00248         m_pLog->WriteMessage(sMsg);
00249 }

void CErrorHandler::WriteStaticError ( const std::string &  rClass,
const std::string &  rMethod,
const std::string &  rError 
) [static, inherited]

Definition at line 192 of file ErrorHandler.cpp.

00195 {
00196     //Do we have a log?
00197     if (!m_pLog)
00198         return;
00199 
00200     //Format the msg
00201     std::string sError;
00202     sError=FormatData(rClass,
00203                       rMethod,
00204                       rError);
00205 
00206     //Write it
00207     m_pLog->WriteError(sError);
00208 }

void CErrorHandler::WriteStaticMessage ( const std::string &  rClass,
const std::string &  rMethod,
const std::string &  rMessage 
) [static, inherited]

Definition at line 210 of file ErrorHandler.cpp.

00213 {
00214     //Do we have a log?
00215     if (!m_pLog)
00216         return;
00217 
00218     //Format the msg
00219     std::string sMsg;
00220     sMsg=FormatData(rClass,
00221                     rMethod,
00222                     rMessage,
00223                     false);
00224 }


Friends And Related Function Documentation

friend class CIPCrafter [friend, inherited]

Definition at line 59 of file Socket.h.


Member Data Documentation

CGenericCriticalSection * CSocketBase::m_pCSection = NULL [static, protected, inherited]

Definition at line 122 of file SocketBase.h.


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