Пример #1
0
 /// <returns>
 /// E_SUCCESS:              Heartbeat success.
 /// E_FAILURE:              Could not connect to the remote IPE.
 /// E_NETWORK_RECV_FAILURE: Heartbeat sent, but AckPackage not received.
 /// E_NETWORK_SEND_FAILURE: Heartbeat could not be sent.
 /// E_RPC_EXCEPTION:        The remote handler throw an exception.
 /// </returns>
 internal TrinityErrorCode Heartbeat()
 {
     if (!sock_connected && !DoConnect(1))   // cannot connect
     {
         return(TrinityErrorCode.E_FAILURE); // TODO error code for connection error
     }
     if (CNativeNetwork.ClientSend(socket, HeartbeatBuffer, 8))
     {
         return(WaitForAckPackage());
     }
     else
     {
         // ClientSend failed.
         FailureHandlerRegistry.MachineFailover(ipe);
         sock_connected = false;
         return(TrinityErrorCode.E_NETWORK_SEND_FAILURE);
     }
 }
Пример #2
0
        private bool DoSend(byte *buf, int len)
        {
            if (!sock_connected && !DoConnect(1)) // cannot connect
            {
                return(false);
            }

            if (CNativeNetwork.ClientSend(socket, buf, len))
            {
                return(true);
            }
            else
            {
                // ClientSend failed.
                sock_connected = false;
                return(false);
            }
        }