![]() |
CClientSocket::OnSocketReceive() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Private Function (Not Declared) |
Declared in: TCPRelay.h |
BOOL CClientSocket::OnSocketReceive( int iErrorCode);
try { if (iErrorCode) { //Report it ReportError("OnSocketReceive","Received an error code!",iErrorCode); //Done return FALSE; } //Do we have a timer if (m_bIncoming && m_pFather->GetTimeout()) //Set it if (!SetTimeout(m_pFather->GetTimeout())) //Report it ReportError("OnSocketReceive","Failed to set timeout!"); //Do we have a CS if (m_pCSection) { //Lock CCriticalAutoRelease aRelease(m_pCSection); //Are we connected if (m_aConnectionID) { //No more events m_bEvent=FALSE; //Save CS CGenericCriticalSection* pCS; pCS=m_pCSection; m_pCSection=NULL; //Exit the CS aRelease.Exit(); //We can delete the CS delete pCS; } else { //Set we have an event m_bEvent=TRUE; //Exit return TRUE; } } char cBuffer[2000]; //Read the data int iResult; iResult=Receive(cBuffer, sizeof(cBuffer)-1); //Try to modify it if (iResult>=0) { //Terminate the string cBuffer[iResult]=0; //Get the modified string std::string sModifiedString; sModifiedString=m_pFather->ModifyReceiveString(m_bIncoming, cBuffer, iResult); //Is it modified? if (!sModifiedString.empty()) { //Replace the buffer strcpy(cBuffer, sModifiedString.c_str()); //Set the size iResult=sModifiedString.size(); } } //Save the socket CClientSocket* pSocket; pSocket=m_pSocket; //Do we have anything if (iResult>0) if (pSocket && pSocket->Send(cBuffer, iResult)<=0) { //Report it ReportErrorOS("OnSocketReceive","Failed to send data!"); //Exit return FALSE; } else ; else if (iResult==GetErrorCode()) { //Report it ReportErrorOS("OnSocketReceive","Failed to receive data!"); //Exit return FALSE; } //Done return TRUE; } ERROR_HANDLER_RETURN("OnSocketReceive",FALSE)
![]() |
Site content copyright © 2003 Komodia LTD.. See the About page for additional notices. This page last updated: 24 Feb 2003. |