/src/Manos.IO/Manos.IO/ISocket.cs

http://github.com/jacksonh/manos · C# · 89 lines · 29 code · 9 blank · 51 comment · 0 complexity · 91fcd0a80109a9fbb03afc0d9af7b035 MD5 · raw file

  1. using System;
  2. using System.Net;
  3. namespace Manos.IO
  4. {
  5. /// <summary>
  6. /// Every socket is bound to an event loop and has it's end points identified by an appropriate
  7. /// implementing class of <see cref="System.Net.EndPoint"/>.
  8. /// <seealso cref="Manos.IO.IStream{TFragment}"/>
  9. /// </summary>
  10. public interface ISocket<TEndPoint> : IDisposable
  11. where TEndPoint : EndPoint
  12. {
  13. /// <summary>
  14. /// Gets the address family of the socket.
  15. /// </summary>
  16. /// <value>
  17. /// The address family.
  18. /// </value>
  19. AddressFamily AddressFamily {
  20. get;
  21. }
  22. /// <summary>
  23. /// Gets whether this socket is connected or not.
  24. /// </summary>
  25. /// <value>
  26. /// <c>true</c> if this socket is connected; otherwise, <c>false</c>.
  27. /// </value>
  28. bool IsConnected {
  29. get;
  30. }
  31. /// <summary>
  32. /// Gets whether this socket is bound to a local address.
  33. /// </summary>
  34. /// <value>
  35. /// <c>true</c> if this socket is bound; otherwise, <c>false</c>.
  36. /// </value>
  37. bool IsBound {
  38. get;
  39. }
  40. /// <summary>
  41. /// Gets the local endpoint of the socket.
  42. /// </summary>
  43. /// <value>
  44. /// The local endpoint.
  45. /// </value>
  46. TEndPoint LocalEndpoint {
  47. get;
  48. }
  49. /// <summary>
  50. /// Gets the remote endpoint of the socket. This may be <c>null</c> for
  51. /// unconnected or connectionless sockets.
  52. /// </summary>
  53. /// <value>
  54. /// The remote endpoint.
  55. /// </value>
  56. TEndPoint RemoteEndpoint {
  57. get;
  58. }
  59. /// <summary>
  60. /// Gets the context the socket is bound to.
  61. /// </summary>
  62. /// <value>
  63. /// The context.
  64. /// </value>
  65. Context Context {
  66. get;
  67. }
  68. /// <summary>
  69. /// Bind the socket to the specified local endpoint.
  70. /// </summary>
  71. /// <param name='endpoint'>
  72. /// Endpoint to bind to.
  73. /// </param>
  74. void Bind (TEndPoint endpoint);
  75. /// <summary>
  76. /// Close this socket and release all resources associated with it.
  77. /// </summary>
  78. void Close ();
  79. }
  80. }