OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 patch class RawServerSocket { | 5 patch class RawServerSocket { |
6 /* patch */ static Future<RawServerSocket> bind(address, | 6 /* patch */ static Future<RawServerSocket> bind(address, |
7 int port, | 7 int port, |
8 {int backlog: 0, | 8 {int backlog: 0, |
9 bool v6Only: false}) { | 9 bool v6Only: false}) { |
10 return _RawServerSocket.bind(address, port, backlog, v6Only); | 10 return _RawServerSocket.bind(address, port, backlog, v6Only); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 final int typeFlags; | 215 final int typeFlags; |
216 | 216 |
217 // Holds the port of the socket, null if not known. | 217 // Holds the port of the socket, null if not known. |
218 int localPort; | 218 int localPort; |
219 | 219 |
220 // Holds the address used to connect or bind the socket. | 220 // Holds the address used to connect or bind the socket. |
221 InternetAddress address; | 221 InternetAddress address; |
222 | 222 |
223 static Future<List<InternetAddress>> lookup( | 223 static Future<List<InternetAddress>> lookup( |
224 String host, {InternetAddressType type: InternetAddressType.ANY}) { | 224 String host, {InternetAddressType type: InternetAddressType.ANY}) { |
225 return IOService.dispatch(SOCKET_LOOKUP, [host, type._value]) | 225 return _IOService.dispatch(_SOCKET_LOOKUP, [host, type._value]) |
226 .then((response) { | 226 .then((response) { |
227 if (isErrorResponse(response)) { | 227 if (isErrorResponse(response)) { |
228 throw createError(response, "Failed host lookup: '$host'"); | 228 throw createError(response, "Failed host lookup: '$host'"); |
229 } else { | 229 } else { |
230 return response.skip(1).map((result) { | 230 return response.skip(1).map((result) { |
231 var type = new InternetAddressType._from(result[0]); | 231 var type = new InternetAddressType._from(result[0]); |
232 return new _InternetAddress(type, result[1], host, result[2]); | 232 return new _InternetAddress(type, result[1], host, result[2]); |
233 }).toList(); | 233 }).toList(); |
234 } | 234 } |
235 }); | 235 }); |
236 } | 236 } |
237 | 237 |
238 static Future<InternetAddress> reverseLookup(InternetAddress addr) { | 238 static Future<InternetAddress> reverseLookup(InternetAddress addr) { |
239 return IOService.dispatch(SOCKET_REVERSE_LOOKUP, [addr._sockaddr_storage]) | 239 return _IOService.dispatch(_SOCKET_REVERSE_LOOKUP, [addr._sockaddr_storage]) |
240 .then((response) { | 240 .then((response) { |
241 if (isErrorResponse(response)) { | 241 if (isErrorResponse(response)) { |
242 throw createError(response, "Failed reverse host lookup", addr); | 242 throw createError(response, "Failed reverse host lookup", addr); |
243 } else { | 243 } else { |
244 return addr._cloneWithNewHost(response); | 244 return addr._cloneWithNewHost(response); |
245 } | 245 } |
246 }); | 246 }); |
247 } | 247 } |
248 | 248 |
249 static Future<List<NetworkInterface>> listInterfaces({ | 249 static Future<List<NetworkInterface>> listInterfaces({ |
250 bool includeLoopback: false, | 250 bool includeLoopback: false, |
251 bool includeLinkLocal: false, | 251 bool includeLinkLocal: false, |
252 InternetAddressType type: InternetAddressType.ANY}) { | 252 InternetAddressType type: InternetAddressType.ANY}) { |
253 return IOService.dispatch(SOCKET_LIST_INTERFACES, [type._value]) | 253 return _IOService.dispatch(_SOCKET_LIST_INTERFACES, [type._value]) |
254 .then((response) { | 254 .then((response) { |
255 if (isErrorResponse(response)) { | 255 if (isErrorResponse(response)) { |
256 throw createError(response, "Failed listing interfaces"); | 256 throw createError(response, "Failed listing interfaces"); |
257 } else { | 257 } else { |
258 var list = new List<NetworkInterface>(); | 258 var list = new List<NetworkInterface>(); |
259 var map = response.skip(1) | 259 var map = response.skip(1) |
260 .fold(new Map<String, List<InternetAddress>>(), (map, result) { | 260 .fold(new Map<String, List<InternetAddress>>(), (map, result) { |
261 var type = new InternetAddressType._from(result[0]); | 261 var type = new InternetAddressType._from(result[0]); |
262 var name = result[3]; | 262 var name = result[3]; |
263 var address = new _InternetAddress( | 263 var address = new _InternetAddress( |
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1209 if (_detachReady != null) { | 1209 if (_detachReady != null) { |
1210 _detachReady.complete(null); | 1210 _detachReady.complete(null); |
1211 } else { | 1211 } else { |
1212 if (_raw != null) { | 1212 if (_raw != null) { |
1213 _raw.shutdown(SocketDirection.SEND); | 1213 _raw.shutdown(SocketDirection.SEND); |
1214 _disableWriteEvent(); | 1214 _disableWriteEvent(); |
1215 } | 1215 } |
1216 } | 1216 } |
1217 } | 1217 } |
1218 } | 1218 } |
OLD | NEW |