nsISocketTransportService.idl 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "nsISupports.idl"
  6. interface nsIFile;
  7. interface nsISocketTransport;
  8. interface nsIProxyInfo;
  9. interface nsIRunnable;
  10. %{C++
  11. class nsASocketHandler;
  12. struct PRFileDesc;
  13. %}
  14. [ptr] native PRFileDescPtr(PRFileDesc);
  15. [ptr] native nsASocketHandlerPtr(nsASocketHandler);
  16. [scriptable, uuid(ad56b25f-e6bb-4db3-9f7b-5b7db33fd2b1)]
  17. interface nsISocketTransportService : nsISupports
  18. {
  19. /**
  20. * Creates a transport for a specified host and port.
  21. *
  22. * @param aSocketTypes
  23. * array of socket type strings. null if using default socket type.
  24. * @param aTypeCount
  25. * specifies length of aSocketTypes.
  26. * @param aHost
  27. * specifies the target hostname or IP address literal of the peer
  28. * for this socket.
  29. * @param aPort
  30. * specifies the target port of the peer for this socket.
  31. * @param aProxyInfo
  32. * specifies the transport-layer proxy type to use. null if no
  33. * proxy. used for communicating information about proxies like
  34. * SOCKS (which are transparent to upper protocols).
  35. *
  36. * @see nsIProxiedProtocolHandler
  37. * @see nsIProtocolProxyService::GetProxyInfo
  38. *
  39. * NOTE: this function can be called from any thread
  40. */
  41. nsISocketTransport createTransport([array, size_is(aTypeCount)]
  42. in string aSocketTypes,
  43. in unsigned long aTypeCount,
  44. in AUTF8String aHost,
  45. in long aPort,
  46. in nsIProxyInfo aProxyInfo);
  47. /**
  48. * Create a transport built on a Unix domain socket, connecting to the
  49. * given filename.
  50. *
  51. * Since Unix domain sockets are always local to the machine, they are
  52. * not affected by the nsIIOService's 'offline' flag.
  53. *
  54. * On systems that don't support Unix domain sockets at all, this
  55. * returns NS_ERROR_SOCKET_ADDRESS_NOT_SUPPORTED.
  56. *
  57. * The system-level socket API may impose restrictions on the length of
  58. * the filename that are stricter than those of the underlying
  59. * filesystem. If the file name is too long, this returns
  60. * NS_ERROR_FILE_NAME_TOO_LONG.
  61. *
  62. * The |aPath| parameter must specify an existing directory entry.
  63. * Otherwise, this returns NS_ERROR_FILE_NOT_FOUND.
  64. *
  65. * The program must have search permission on all components of the
  66. * path prefix of |aPath|, and read and write permission on |aPath|
  67. * itself. Without such permission, this returns
  68. * NS_ERROR_CONNECTION_REFUSED.
  69. *
  70. * The |aPath| parameter must refer to a unix-domain socket. Otherwise,
  71. * this returns NS_ERROR_CONNECTION_REFUSED. (POSIX specifies
  72. * ECONNREFUSED when "the target address was not listening for
  73. * connections", and this is what Linux returns.)
  74. *
  75. * @param aPath
  76. * The file name of the Unix domain socket to which we should
  77. * connect.
  78. */
  79. nsISocketTransport createUnixDomainTransport(in nsIFile aPath);
  80. /**
  81. * Adds a new socket to the list of controlled sockets.
  82. *
  83. * This will fail with the error code NS_ERROR_NOT_AVAILABLE if the maximum
  84. * number of sockets is already reached.
  85. * In this case, the notifyWhenCanAttachSocket method should be used.
  86. *
  87. * @param aFd
  88. * Open file descriptor of the socket to control.
  89. * @param aHandler
  90. * Socket handler that will receive notifications when the socket is
  91. * ready or detached.
  92. *
  93. * NOTE: this function may only be called from an event dispatch on the
  94. * socket thread.
  95. */
  96. [noscript] void attachSocket(in PRFileDescPtr aFd,
  97. in nsASocketHandlerPtr aHandler);
  98. /**
  99. * if the number of sockets reaches the limit, then consumers can be
  100. * notified when the number of sockets becomes less than the limit. the
  101. * notification is asynchronous, delivered via the given nsIRunnable
  102. * instance on the socket transport thread.
  103. *
  104. * @param aEvent
  105. * Event that will receive the notification when a new socket can
  106. * be attached
  107. *
  108. * NOTE: this function may only be called from an event dispatch on the
  109. * socket thread.
  110. */
  111. [noscript] void notifyWhenCanAttachSocket(in nsIRunnable aEvent);
  112. };
  113. [scriptable, uuid(c5204623-5b58-4a16-8b2e-67c34dd02e3f)]
  114. interface nsIRoutedSocketTransportService : nsISocketTransportService
  115. {
  116. // use this instead of createTransport when you have a transport
  117. // that distinguishes between origin and route (aka connection)
  118. nsISocketTransport createRoutedTransport([array, size_is(aTypeCount)]
  119. in string aSocketTypes,
  120. in unsigned long aTypeCount,
  121. in AUTF8String aHost, // origin
  122. in long aPort, // origin
  123. in AUTF8String aHostRoute,
  124. in long aPortRoute,
  125. in nsIProxyInfo aProxyInfo);
  126. };