TcpTransportBindingElement.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. //
  2. // TcpTransportBindingElement.cs
  3. //
  4. // Authors:
  5. // Atsushi Enomoto <[email protected]>
  6. // Marcos Cobena ([email protected])
  7. //
  8. // Copyright (C) 2005 Novell, Inc. http://www.novell.com
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. using System;
  30. using System.Collections.Generic;
  31. using System.Net;
  32. using System.ServiceModel.Channels;
  33. using System.ServiceModel.Description;
  34. namespace System.ServiceModel.Channels
  35. {
  36. [MonoTODO]
  37. public class TcpTransportBindingElement
  38. : ConnectionOrientedTransportBindingElement
  39. {
  40. internal const int DefaultPort = 808;
  41. int listen_backlog = 10;
  42. bool port_sharing_enabled = false;
  43. bool teredo_enabled = false;
  44. TcpConnectionPoolSettings pool = new TcpConnectionPoolSettings ();
  45. public TcpTransportBindingElement ()
  46. {
  47. }
  48. protected TcpTransportBindingElement (
  49. TcpTransportBindingElement other)
  50. : base (other)
  51. {
  52. listen_backlog = other.listen_backlog;
  53. port_sharing_enabled = other.port_sharing_enabled;
  54. pool.CopyPropertiesFrom (other.pool);
  55. }
  56. public TcpConnectionPoolSettings ConnectionPoolSettings {
  57. get { return pool; }
  58. }
  59. public int ListenBacklog {
  60. get { return listen_backlog; }
  61. set { listen_backlog = value; }
  62. }
  63. public bool PortSharingEnabled {
  64. get { return port_sharing_enabled; }
  65. set { port_sharing_enabled = value; }
  66. }
  67. public override string Scheme {
  68. get { return "net.tcp"; }
  69. }
  70. // As MSDN exposes, this' only available on Windows XP SP2 and Windows Server 2003
  71. public bool TeredoEnabled {
  72. get { return teredo_enabled; }
  73. set { teredo_enabled = value; }
  74. }
  75. [MonoTODO]
  76. public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (
  77. BindingContext context)
  78. {
  79. return new TcpChannelFactory<TChannel> (this, context);
  80. }
  81. [MonoTODO]
  82. public override IChannelListener<TChannel>
  83. BuildChannelListener<TChannel> (
  84. BindingContext context)
  85. {
  86. return new TcpChannelListener<TChannel> (this, context);
  87. }
  88. public override BindingElement Clone ()
  89. {
  90. return new TcpTransportBindingElement (this);
  91. }
  92. [MonoTODO]
  93. public override T GetProperty<T> (BindingContext context)
  94. {
  95. // FIXME: ... or return ISecurityCapabilities?
  96. return context.GetInnerProperty<T> ();
  97. }
  98. }
  99. }