V1/Cet.Develop.WP.IO/Net/SocketClient.cs
/// <summary>
/// Entry-point for submitting a query to the remote device
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
Entry-point for submitting a query to the remote device
Entry - point for submitting a query to the remote device
public CommResponse Query(ClientCommData data)
        {
            byte[] outgoing = data
                .OutgoingData
                .ToArray();
            int totalTimeout = this.Latency + data.Timeout;
            for (int attempt = 0, retries = data.Retries; attempt < retries; attempt++)
            {
                this.Send(outgoing);
                var incoming = new ByteArrayWriter();
                incoming.WriteBytes(
                    this.Receive(totalTimeout)
                    );
                data.IncomingData = incoming.ToReader();
                CommResponse result = data
                    .OwnerProtocol
                    .Codec
                    .ClientDecode(data);
                if (result.Status == CommResponse.Ack)
                {
                    return result;
                }
                else if (result.Status == CommResponse.Critical)
                {
                    return result;
                }
                else if (result.Status != CommResponse.Unknown)
                {
                    break;
                }
            }       
            return new CommResponse(
                data,
                CommResponse.Critical);
        }
public CommResponse Query ( ClientCommData data ) { byte [ ] outgoing = data . OutgoingData . ToArray ( ) ; int totalTimeout = this . Latency + data . Timeout ; for ( int attempt = 0 , retries = data . Retries ; attempt < retries ; attempt ++ ) { this . Send ( outgoing ) ; var incoming = new ByteArrayWriter ( ) ; incoming . WriteBytes ( this . Receive ( totalTimeout ) ) ; data . IncomingData = incoming . ToReader ( ) ; CommResponse result = data . OwnerProtocol . Codec . ClientDecode ( data ) ; if ( result . Status == CommResponse . Ack ) { return result ; } else if ( result . Status == CommResponse . Critical ) { return result ; } else if ( result . Status != CommResponse . Unknown ) { break ; } } return new CommResponse ( data , CommResponse . Critical ) ; }
Entry-point for submitting a query to the remote device
Entry - point for submitting a query to the remote device
//convert the request data as an ordinary byte array //retries loop //phyiscal writing //create a writer for accumulate the incoming data //read the incoming data from the physical port //try to decode the stream //exit whether any concrete result: either good or bad //stop immediately if the host asked to abort //TODO //for //no attempt was successful
None
data
ClientCommData
None