Пример #1
0
/*
*	-1:recv error
	-2:recv timeout
	-3:recv invalid data
	-4:send error
	-5:send timeout		
	0:closed
	>0:ok,the pack len is returned.
*/
int CBaseSocket::SendRecv(
		const char *req,
		unsigned int req_len, 
		pfHandleInput pf,
		unsigned int hlen,    		
		char *rsp, 
		unsigned int rsp_len,  
		int timeout,
		int flags)
{
    unsigned int nwrite = 0;
    int ret = SendN(nwrite, req, req_len, timeout);

    if(nwrite != req_len)
    {
        if(ret == 0)
        {
            return 0;
        }
        
        if(ret == -2)
        {
            return -5;
        }
        return -4;
    }
	
    return RecvPack(pf, hlen, rsp_len, rsp, rsp_len, timeout);
}
bool CCiMulticastSocket::SendInt32(unsigned int uiValue)
{
	unsigned int uiValueToSend = htonl(uiValue);

	if ( !SendN( &uiValueToSend, sizeof( int ) ) ) {
		return false;
	}

	return true;
}
bool CCiMulticastSocket::FlushSendBuffer()
{
	return SendN(m_sendBuffer, m_iSendBufferPosition);
}