Beispiel #1
0
bool rpc_handler_node::handle_req_hello(rpc_connection& connection,
                                        uint64_t xid,
                                        const message::req_hello& message) {
    if (!rpc_handler::handle_req_hello(connection, xid, message))
        return false;

    message::rpc_message reply;
    reply.set_method(message::METHOD_HELLO);
    reply.mutable_rep()->mutable_hello();
    connection.send_message(reply);
    LOG(INFO) << HTAG << "Handshake succeeded";

    return handle_ready(connection);
}
Beispiel #2
0
	int CTcpConnector::Readn_ms(void *pMsg, int iLen,unsigned int timeout)
	{
		struct timeval tm;
		tm.tv_sec = timeout/1000;
		tm.tv_usec = (timeout%1000)*1000;
		int res; 
		if((res = handle_ready(m_sockfd,tm,1,0,0))>0)
		{ 
			char *pBuf =(char*)pMsg;
			int bytes_read = 0;

			int this_read;
			while( bytes_read < iLen )
			{
				do
				{
					this_read = read(m_sockfd, pBuf, iLen - bytes_read);
				}
				while ( ( this_read < 0 )  && ( errno == EINTR ) );

				if (this_read < 0)
				{
					return this_read;
				}
				else if(this_read == 0) {
					return bytes_read;
				}

				bytes_read += this_read;

				pBuf += this_read;
			}
			return bytes_read;
		}
		else  
		{
			return -1; 
		}
	}