Finish() public method

public Finish ( byte &data ) : int
data byte
return int
示例#1
0
 protected TCPBinaryReader SendReceive(TCPBinaryWriter request)
 {
     lock (m_Lock)
     {
         OpenIfClosed();
         //
         byte[] data;
         var dataSize = request.Finish(out data);
         var stream = m_TcpClient.GetStream();
         stream.Write(data, 0, dataSize);
         stream.Flush();
         //
         var recvData = new TCPBinaryReader(TCPCommunicationSignature.Response, ReadBuffer);
         if (!recvData.IsComplete)
             throw new IOException("Incomplete response received");
         if (recvData.Command == TCPCommunicationSignature.CmdException)
         {
             throw HandleErrorResponse(recvData);
         }
         if (recvData.Command != request.Command && recvData.Command != TCPCommunicationSignature.CmdException)
             throw new InvalidProtocolException("Invalid response command");
         return recvData;
     }
 }
示例#2
0
 private void SendCloseCommand()
 {
     lock (m_Lock)
     {
         var request = new TCPBinaryWriter(TCPCommunicationSignature.Request, TCPCommunicationSignature.CmdClose);
         byte[] data;
         var dataSize = request.Finish(out data);
         var stream = m_TcpClient.GetStream();
         stream.Write(data, 0, dataSize);
         stream.Flush();
     }
 }