Exemplo n.º 1
0
//////////////////////////
//	Receive ASCII (term)
//////////////////////////
bool CMimeProtocol::receive(int link,char *pszBuffer,int nMaxSize,char *pszTerminator)
{
	char szTmpBuffer[CBUFF_MASSIVE];
	char *pszTerm;
	
	int nBytes = 0;
	int nReceived = 0;

	//	Reset
	strcpy(pszBuffer,"");

	//	Forever
	while(!(pszTerm = strstr(pszBuffer,pszTerminator))){

		//	Receive bytes from socket
		//nBytes = recvTcp(link,&szTmpBuffer[nReceived],nMaxSize-nReceived);
		nBytes = recvTcp(link,&pszBuffer[nReceived],nMaxSize-nReceived);

		if(nBytes == -1){

			if(OSALASTERROR != OSAWOULDBLOCK)
				return false;

			OSASleep(5);
			continue;
		}

		//	Check for end
		if(nBytes == 0 || nBytes == -1)
			return false;

		//	Check for error
		if(nBytes <= -1)
			return false;

		//	Copy data
		szTmpBuffer[nBytes] = 0;

		//	Check limits
		if(nReceived + nBytes >= nMaxSize)
			return false;

		nReceived += nBytes;
	}

	//	Success (remove terminator)
	pszBuffer[minimal(nReceived,nMaxSize)]=0;

	//*pszTerm = 0;
	return true;
}
Exemplo n.º 2
0
///////////////////////////////////////////////////
//	Cleanup
///////////////////////////////////////////////////
void CSNAPIClient::shutdown()
{
	//	Force conference close
	if(grpHandle != MEDIA_INVALID){

		int cmdId;

		if(getGrpCmd(cmdId,"terminategrp"))
			exeGrpCmd(cmdId);

		grpHandle = MEDIA_INVALID;
		OSASleep(250);
	}

	CMediaClient::shutdown();
	lub.shutdown();
}