Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: sdk/lib/io/secure_server_socket.dart

Issue 14640008: Change the signature for all network bind calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments by whesse@ Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | sdk/lib/io/socket.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.io; 5 part of dart.io;
6 6
7 /** 7 /**
8 * The [SecureServerSocket] is a server socket, providing a stream of high-level 8 * The [SecureServerSocket] is a server socket, providing a stream of high-level
9 * [Socket]s. 9 * [Socket]s.
10 * 10 *
11 * See [SecureSocket] for more info. 11 * See [SecureSocket] for more info.
12 */ 12 */
13 class SecureServerSocket extends Stream<SecureSocket> implements ServerSocket { 13 class SecureServerSocket extends Stream<SecureSocket> implements ServerSocket {
14 final RawSecureServerSocket _socket; 14 final RawSecureServerSocket _socket;
15 15
16 SecureServerSocket._(RawSecureServerSocket this._socket); 16 SecureServerSocket._(RawSecureServerSocket this._socket);
17 17
18 /** 18 /**
19 * Returns a future for a [SecureServerSocket]. When the future 19 * Returns a future for a [SecureServerSocket]. When the future
20 * completes the server socket is bound to the given [address] and 20 * completes the server socket is bound to the given [address] and
21 * [port] and has started listening on it. 21 * [port] and has started listening on it.
22 * 22 *
23 * If [port] has the value [:0:] (the default) an ephemeral port will 23 * The [address] can either be a [String] or an
24 * be chosen by the system. The actual port used can be retrieved 24 * [InternetAddress]. If [address] is a [String], [bind] will
25 * using the [port] getter. 25 * perform a [InternetAddress.lookup] and use the first value in the
26 * list. To listen on the loopback adapter, which will allow only
27 * incoming connections from the local host, use the value
28 * [InternetAddress.LOOPBACK_IP_V4] or
29 * [InternetAddress.LOOPBACK_IP_V6]. To allow for incoming
30 * connection from the network use either one of the values
31 * [InternetAddress.ANY_IP_V4] or [InternetAddress.ANY_IP_V6] to
32 * bind to all interfaces or the IP address of a specific interface.
26 * 33 *
27 * If [backlog] has the value of [:0:] a reasonable value will be 34 * If [port] has the value [:0:] an ephemeral port will be chosen by
28 * chosen by the system. 35 * the system. The actual port used can be retrieved using the
36 * [port] getter.
37 *
38 * The optional argument [backlog] can be used to specify the listen
39 * backlog for the underlying OS listen setup. If [backlog] has the
40 * value of [:0:] (the default) a reasonable value will be chosen by
41 * the system.
29 * 42 *
30 * Incoming client connections are promoted to secure connections, using 43 * Incoming client connections are promoted to secure connections, using
31 * the server certificate given by [certificateName]. 44 * the server certificate given by [certificateName].
32 * 45 *
33 * [address] must be given as a numeric address, not a host name. 46 * [address] must be given as a numeric address, not a host name.
34 * 47 *
35 * [certificateName] is the nickname or the distinguished name (DN) of 48 * [certificateName] is the nickname or the distinguished name (DN) of
36 * the certificate in the certificate database. It is looked up in the 49 * the certificate in the certificate database. It is looked up in the
37 * NSS certificate database set by SecureSocket.setCertificateDatabase. 50 * NSS certificate database set by SecureSocket.setCertificateDatabase.
38 * If [certificateName] contains "CN=", it is assumed to be a distinguished 51 * If [certificateName] contains "CN=", it is assumed to be a distinguished
39 * name. Otherwise, it is looked up as a nickname. 52 * name. Otherwise, it is looked up as a nickname.
40 * 53 *
41 * To request or require that clients authenticate by providing an SSL (TLS) 54 * To request or require that clients authenticate by providing an SSL (TLS)
42 * client certificate, set the optional parameter [requestClientCertificate] 55 * client certificate, set the optional parameter [requestClientCertificate]
43 * or [requireClientCertificate] to true. Requiring a certificate implies 56 * or [requireClientCertificate] to true. Requiring a certificate implies
44 * requesting a certificate, so one doesn't need to set both to true. 57 * requesting a certificate, so one doesn't need to set both to true.
45 * To check whether a client certificate was received, check 58 * To check whether a client certificate was received, check
46 * SecureSocket.peerCertificate after connecting. If no certificate 59 * SecureSocket.peerCertificate after connecting. If no certificate
47 * was received, the result will be null. 60 * was received, the result will be null.
48 */ 61 */
49 static Future<SecureServerSocket> bind( 62 static Future<SecureServerSocket> bind(
50 String address, 63 address,
51 int port, 64 int port,
52 int backlog,
53 String certificateName, 65 String certificateName,
54 {bool requestClientCertificate: false, 66 {int backlog: 0,
67 bool requestClientCertificate: false,
55 bool requireClientCertificate: false}) { 68 bool requireClientCertificate: false}) {
56 return RawSecureServerSocket.bind( 69 return RawSecureServerSocket.bind(
57 address, 70 address,
58 port, 71 port,
59 backlog,
60 certificateName, 72 certificateName,
73 backlog: backlog,
61 requestClientCertificate: requestClientCertificate, 74 requestClientCertificate: requestClientCertificate,
62 requireClientCertificate: requireClientCertificate).then( 75 requireClientCertificate: requireClientCertificate).then(
63 (serverSocket) => new SecureServerSocket._(serverSocket)); 76 (serverSocket) => new SecureServerSocket._(serverSocket));
64 } 77 }
65 78
66 StreamSubscription<SecureSocket> listen(void onData(SecureSocket socket), 79 StreamSubscription<SecureSocket> listen(void onData(SecureSocket socket),
67 {void onError(error), 80 {void onError(error),
68 void onDone(), 81 void onDone(),
69 bool cancelOnError}) { 82 bool cancelOnError}) {
70 return _socket.map((rawSocket) => new SecureSocket._(rawSocket)) 83 return _socket.map((rawSocket) => new SecureSocket._(rawSocket))
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 onPause: _onPauseStateChange, 124 onPause: _onPauseStateChange,
112 onResume: _onPauseStateChange, 125 onResume: _onPauseStateChange,
113 onCancel: _onSubscriptionStateChange); 126 onCancel: _onSubscriptionStateChange);
114 } 127 }
115 128
116 /** 129 /**
117 * Returns a future for a [RawSecureServerSocket]. When the future 130 * Returns a future for a [RawSecureServerSocket]. When the future
118 * completes the server socket is bound to the given [address] and 131 * completes the server socket is bound to the given [address] and
119 * [port] and has started listening on it. 132 * [port] and has started listening on it.
120 * 133 *
121 * If [port] has the value [:0:] (the default) an ephemeral port will 134 * The [address] can either be a [String] or an
122 * be chosen by the system. The actual port used can be retrieved 135 * [InternetAddress]. If [address] is a [String], [bind] will
123 * using the [port] getter. 136 * perform a [InternetAddress.lookup] and use the first value in the
137 * list. To listen on the loopback adapter, which will allow only
138 * incoming connections from the local host, use the value
139 * [InternetAddress.LOOPBACK_IP_V4] or
140 * [InternetAddress.LOOPBACK_IP_V6]. To allow for incoming
141 * connection from the network use either one of the values
142 * [InternetAddress.ANY_IP_V4] or [InternetAddress.ANY_IP_V6] to
143 * bind to all interfaces or the IP address of a specific interface.
124 * 144 *
125 * If [backlog] has the value of [:0:] a reasonable value will be 145 * If [port] has the value [:0:] an ephemeral port will be chosen by
126 * chosen by the system. 146 * the system. The actual port used can be retrieved using the
147 * [port] getter.
148 *
149 * The optional argument [backlog] can be used to specify the listen
150 * backlog for the underlying OS listen setup. If [backlog] has the
151 * value of [:0:] (the default) a reasonable value will be chosen by
152 * the system.
127 * 153 *
128 * Incoming client connections are promoted to secure connections, 154 * Incoming client connections are promoted to secure connections,
129 * using the server certificate given by [certificateName]. 155 * using the server certificate given by [certificateName].
130 * 156 *
131 * [address] must be given as a numeric address, not a host name. 157 * [address] must be given as a numeric address, not a host name.
132 * 158 *
133 * [certificateName] is the nickname or the distinguished name (DN) of 159 * [certificateName] is the nickname or the distinguished name (DN) of
134 * the certificate in the certificate database. It is looked up in the 160 * the certificate in the certificate database. It is looked up in the
135 * NSS certificate database set by SecureSocket.setCertificateDatabase. 161 * NSS certificate database set by SecureSocket.setCertificateDatabase.
136 * If [certificateName] contains "CN=", it is assumed to be a distinguished 162 * If [certificateName] contains "CN=", it is assumed to be a distinguished
137 * name. Otherwise, it is looked up as a nickname. 163 * name. Otherwise, it is looked up as a nickname.
138 * 164 *
139 * To request or require that clients authenticate by providing an SSL (TLS) 165 * To request or require that clients authenticate by providing an SSL (TLS)
140 * client certificate, set the optional parameters requestClientCertificate or 166 * client certificate, set the optional parameters requestClientCertificate or
141 * requireClientCertificate to true. Require implies request, so one doesn't 167 * requireClientCertificate to true. Require implies request, so one doesn't
142 * need to specify both. To check whether a client certificate was received, 168 * need to specify both. To check whether a client certificate was received,
143 * check SecureSocket.peerCertificate after connecting. If no certificate 169 * check SecureSocket.peerCertificate after connecting. If no certificate
144 * was received, the result will be null. 170 * was received, the result will be null.
145 */ 171 */
146 static Future<RawSecureServerSocket> bind( 172 static Future<RawSecureServerSocket> bind(
147 String address, 173 String address,
148 int port, 174 int port,
149 int backlog,
150 String certificateName, 175 String certificateName,
151 {bool requestClientCertificate: false, 176 {int backlog: 0,
177 bool requestClientCertificate: false,
152 bool requireClientCertificate: false}) { 178 bool requireClientCertificate: false}) {
153 return RawServerSocket.bind(address, port, backlog) 179 return RawServerSocket.bind(address, port, backlog: backlog)
154 .then((serverSocket) => new RawSecureServerSocket._( 180 .then((serverSocket) => new RawSecureServerSocket._(
155 serverSocket, 181 serverSocket,
156 certificateName, 182 certificateName,
157 requestClientCertificate, 183 requestClientCertificate,
158 requireClientCertificate)); 184 requireClientCertificate));
159 } 185 }
160 186
161 StreamSubscription<RawSecureSocket> listen(void onData(RawSecureSocket s), 187 StreamSubscription<RawSecureSocket> listen(void onData(RawSecureSocket s),
162 {void onError(error), 188 {void onError(error),
163 void onDone(), 189 void onDone(),
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 _subscription = _socket.listen(_onData, 254 _subscription = _socket.listen(_onData,
229 onDone: _onDone, 255 onDone: _onDone,
230 onError: _onError); 256 onError: _onError);
231 } else { 257 } else {
232 close(); 258 close();
233 } 259 }
234 } 260 }
235 } 261 }
236 262
237 263
OLDNEW
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | sdk/lib/io/socket.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698