TcpSocketServerConfiguration.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System;
  2. using System.Net.Security;
  3. using System.Net.Sockets;
  4. using System.Security.Authentication;
  5. using System.Security.Cryptography.X509Certificates;
  6. using MECF.Framework.Common.Communications.Tcp.Buffer;
  7. using MECF.Framework.Common.Communications.Tcp.Socket.Framing;
  8. using MECF.Framework.Common.Communications.Tcp.Socket.Framing.Base;
  9. namespace MECF.Framework.Common.Communications.Tcp.Socket.Server.APM
  10. {
  11. public sealed class TcpSocketServerConfiguration
  12. {
  13. public TcpSocketServerConfiguration()
  14. : this(new SegmentBufferManager(1024, 8192, 1, true))
  15. {
  16. }
  17. public TcpSocketServerConfiguration(ISegmentBufferManager bufferManager)
  18. {
  19. BufferManager = bufferManager;
  20. ReceiveBufferSize = 8192;
  21. SendBufferSize = 8192;
  22. ReceiveTimeout = TimeSpan.Zero;
  23. SendTimeout = TimeSpan.Zero;
  24. NoDelay = true;
  25. LingerState = new LingerOption(false, 0);
  26. KeepAlive = false;
  27. KeepAliveInterval = TimeSpan.FromSeconds(5);
  28. ReuseAddress = false;
  29. PendingConnectionBacklog = 200;
  30. AllowNatTraversal = true;
  31. SslEnabled = false;
  32. SslServerCertificate = null;
  33. SslEncryptionPolicy = EncryptionPolicy.RequireEncryption;
  34. SslEnabledProtocols = SslProtocols.Ssl3 | SslProtocols.Tls;
  35. SslClientCertificateRequired = true;
  36. SslCheckCertificateRevocation = false;
  37. SslPolicyErrorsBypassed = false;
  38. ConnectTimeout = TimeSpan.FromSeconds(15);
  39. FrameBuilder = new LengthPrefixedFrameBuilder();
  40. }
  41. public ISegmentBufferManager BufferManager { get; set; }
  42. public int ReceiveBufferSize { get; set; }
  43. public int SendBufferSize { get; set; }
  44. public TimeSpan ReceiveTimeout { get; set; }
  45. public TimeSpan SendTimeout { get; set; }
  46. public bool NoDelay { get; set; }
  47. public LingerOption LingerState { get; set; }
  48. public bool KeepAlive { get; set; }
  49. public TimeSpan KeepAliveInterval { get; set; }
  50. public bool ReuseAddress { get; set; }
  51. public int PendingConnectionBacklog { get; set; }
  52. public bool AllowNatTraversal { get; set; }
  53. public bool SslEnabled { get; set; }
  54. public X509Certificate2 SslServerCertificate { get; set; }
  55. public EncryptionPolicy SslEncryptionPolicy { get; set; }
  56. public SslProtocols SslEnabledProtocols { get; set; }
  57. public bool SslClientCertificateRequired { get; set; }
  58. public bool SslCheckCertificateRevocation { get; set; }
  59. public bool SslPolicyErrorsBypassed { get; set; }
  60. public TimeSpan ConnectTimeout { get; set; }
  61. public IFrameBuilder FrameBuilder { get; set; }
  62. }
  63. }