ISocketFactory.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. 
  2. using System.IO;
  3. namespace MediaBrowser.Model.Net
  4. {
  5. /// <summary>
  6. /// Implemented by components that can create a platform specific UDP socket implementation, and wrap it in the cross platform <see cref="ISocket"/> interface.
  7. /// </summary>
  8. public interface ISocketFactory
  9. {
  10. /// <summary>
  11. /// Createa a new unicast socket using the specified local port number.
  12. /// </summary>
  13. /// <param name="localPort">The local port to bind to.</param>
  14. /// <returns>A <see cref="ISocket"/> implementation.</returns>
  15. ISocket CreateUdpSocket(int localPort);
  16. ISocket CreateUdpBroadcastSocket(int localPort);
  17. ISocket CreateTcpSocket(IpAddressInfo remoteAddress, int remotePort);
  18. /// <summary>
  19. /// Createa a new unicast socket using the specified local port number.
  20. /// </summary>
  21. ISocket CreateSsdpUdpSocket(IpAddressInfo localIp, int localPort);
  22. /// <summary>
  23. /// Createa a new multicast socket using the specified multicast IP address, multicast time to live and local port.
  24. /// </summary>
  25. /// <param name="ipAddress">The multicast IP address to bind to.</param>
  26. /// <param name="multicastTimeToLive">The multicast time to live value. Actually a maximum number of network hops for UDP packets.</param>
  27. /// <param name="localPort">The local port to bind to.</param>
  28. /// <returns>A <see cref="ISocket"/> implementation.</returns>
  29. ISocket CreateUdpMulticastSocket(string ipAddress, int multicastTimeToLive, int localPort);
  30. IAcceptSocket CreateSocket(IpAddressFamily family, SocketType socketType, ProtocolType protocolType, bool dualMode);
  31. Stream CreateNetworkStream(ISocket socket, bool ownsSocket);
  32. }
  33. public enum SocketType
  34. {
  35. Stream
  36. }
  37. public enum ProtocolType
  38. {
  39. Tcp
  40. }
  41. }