1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is mozilla.org code.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38 #include "nsITransport.idl"
39
40 interface nsIInterfaceRequestor;
41
42 native PRNetAddr(union PRNetAddr);
43
44 /**
45 * nsISocketTransport
46 *
47 * NOTE: Connection setup is triggered by opening an input or output stream,
48 * it does not start on its own. Completion of the connection setup is
49 * indicated by a STATUS_CONNECTED_TO notification to the event sink (if set).
50 *
51 * NOTE: This is a free-threaded interface, meaning that the methods on
52 * this interface may be called from any thread.
53 */
54 [scriptable, uuid(66418cc8-5f5d-4f52-a7f9-db8fb3b2cfe6)]
55 interface nsISocketTransport : nsITransport
56 {
57 /**
58 * Get the host for the underlying socket connection.
59 */
60 readonly attribute AUTF8String host;
61
62 /**
63 * Get the port for the underlying socket connection.
64 */
65 readonly attribute long port;
66
67 /**
68 * Returns the IP address of the socket connection peer. This
69 * attribute is defined only once a connection has been established.
70 */
71 [noscript] PRNetAddr getPeerAddr();
72
73 /**
74 * Returns the IP address of the initiating end. This attribute
75 * is defined only once a connection has been established.
76 */
77 [noscript] PRNetAddr getSelfAddr();
78
79 /**
80 * Security info object returned from the secure socket provider. This
81 * object supports nsISSLSocketControl, nsITransportSecurityInfo, and
82 * possibly other interfaces.
83 *
84 * This attribute is only available once the socket is connected.
85 */
86 readonly attribute nsISupports securityInfo;
87
88 /**
89 * Security notification callbacks passed to the secure socket provider
90 * via nsISSLSocketControl at socket creation time.
91 *
92 * NOTE: this attribute cannot be changed once a stream has been opened.
93 */
94 attribute nsIInterfaceRequestor securityCallbacks;
95
96 /**
97 * Test if this socket transport is (still) connected.
98 */
99 boolean isAlive();
100
101 /**
102 * Socket timeouts in seconds. To specify no timeout, pass PR_UINT32_MAX
103 * as aValue to setTimeout. The implementation may truncate timeout values
104 * to a smaller range of values (e.g., 0 to 0xFFFF).
105 */
106 unsigned long getTimeout(in unsigned long aType);
107 void setTimeout(in unsigned long aType, in unsigned long aValue);
108
109 /**
110 * Values for the aType parameter passed to get/setTimeout.
111 */
112 const unsigned long TIMEOUT_CONNECT = 0;
113 const unsigned long TIMEOUT_READ_WRITE = 1;
114
115 /**
116 * nsITransportEventSink status codes.
117 *
118 * Although these look like XPCOM error codes and are passed in an nsresult
119 * variable, they are *not* error codes. Note that while they *do* overlap
120 * with existing error codes in Necko, these status codes are confined
121 * within a very limited context where no error codes may appear, so there
122 * is no ambiguity.
123 *
124 * The values of these status codes must never change.
125 *
126 * The status codes appear in near-chronological order (not in numeric
127 * order). STATUS_RESOLVING may be skipped if the host does not need to be
128 * resolved. STATUS_WAITING_FOR is an optional status code, which the impl
129 * of this interface may choose not to generate.
130 */
131 const unsigned long STATUS_RESOLVING = 0x804b0003;
132 const unsigned long STATUS_CONNECTING_TO = 0x804b0007;
133 const unsigned long STATUS_CONNECTED_TO = 0x804b0004;
134 const unsigned long STATUS_SENDING_TO = 0x804b0005;
135 const unsigned long STATUS_WAITING_FOR = 0x804b000a;
136 const unsigned long STATUS_RECEIVING_FROM = 0x804b0006;
137 };
138
139 %{C++
140 /**
141 * #define's for compatibility
142 */
143 #define NS_NET_STATUS_RESOLVING_HOST nsISocketTransport::STATUS_RESOLVING
144 #define NS_NET_STATUS_CONNECTED_TO nsISocketTransport::STATUS_CONNECTED_TO
145 #define NS_NET_STATUS_SENDING_TO nsISocketTransport::STATUS_SENDING_TO
146 #define NS_NET_STATUS_RECEIVING_FROM nsISocketTransport::STATUS_RECEIVING_FROM
147 #define NS_NET_STATUS_CONNECTING_TO nsISocketTransport::STATUS_CONNECTING_TO
148 #define NS_NET_STATUS_WAITING_FOR nsISocketTransport::STATUS_WAITING_FOR
149 %}