TcpWireProtocol.cs

 
  1. // ==++==
  2. // 
  3. //   
  4. //    Copyright (c) 2002 Microsoft Corporation.  All rights reserved.
  5. //   
  6. //    The use and distribution terms for this software are contained in the file
  7. //    named license.txt, which can be found in the root of this distribution.
  8. //    By using this software in any fashion, you are agreeing to be bound by the
  9. //    terms of this license.
  10. //   
  11. //    You must not remove this notice, or any other, from this software.
  12. //   
  13. // 
  14. // ==--==
  15. //==========================================================================
  16. //  File:       TcpWireProtocol.cs
  17. //
  18. //  Summary:    Class for managing a socket connection.
  19. //
  20. //==========================================================================
  21. using System;
  22. using System.IO;
  23. using System.Net.Sockets;
  24. using System.Text;
  25. using System.Threading;
  26. namespace System.Runtime.Remoting.Channels.Tcp
  27. {
  28.     // After the version, one of the following 16-bit opcodes will appear.
  29.     internal class TcpOperations
  30.     {
  31.         internal const UInt16 Request       = 0;
  32.         internal const UInt16 OneWayRequest = 1;
  33.         internal const UInt16 Reply         = 2;
  34.     } // TcpOpcodes
  35.     internal class TcpContentDelimiter
  36.     {
  37.         internal const UInt16 ContentLength     = 0; 
  38.         internal const UInt16 Chunked           = 1;
  39.     }
  40.     // These are special header values. (Custom can be used for arbitrary
  41.     //   pairs).
  42.     internal class TcpHeaders
  43.     {
  44.         internal const UInt16 EndOfHeaders      = 0; // (can appear once at end of headers)
  45.         internal const UInt16 Custom            = 1;
  46.         internal const UInt16 StatusCode        = 2;
  47.         internal const UInt16 StatusPhrase      = 3;
  48.         internal const UInt16 RequestUri        = 4;
  49.         internal const UInt16 CloseConnection   = 5;
  50.         internal const UInt16 ContentType       = 6;
  51.     } // TcpHeaders
  52.     // These are used by special headers (non-Custom) to indicate the format of the data,
  53.     //   so that unknown special headers added in the future can be ignored.
  54.     internal class TcpHeaderFormat
  55.     {
  56.         internal const byte Void          = 0; // There is no further data.
  57.         internal const byte CountedString = 1; // A single counted string follows.
  58.         internal const byte Byte          = 2; // A single byte follows
  59.         internal const byte UInt16        = 3; // A single unsigned 16-bit int follows.        
  60.         internal const byte Int32         = 4; // A single 32-bit int follows.
  61.     } // TcpHeaderFormat
  62.     
  63.     // status codes only apply to the transmission of data itself.
  64.     internal class TcpStatusCode
  65.     {
  66.         internal const UInt16 Success      = 0; // data was successfully received
  67.         internal const UInt16 GenericError = 1; // an unknown error occurred
  68.     } // TcpStatusCode
  69.     // string format indicators
  70.     // (strings have the following format on the wire:
  71.     //   [format (1-byte)][encoded-size (int32)][string data (encoded-size bytes in length)]
  72.     internal class TcpStringFormat
  73.     {
  74.         internal const byte Unicode = 0;
  75.         internal const byte UTF8    = 1;
  76.     } // TcpStringFormat
  77.     
  78. // namespace System.Runtime.Remoting.Channels.Tcp
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值