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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 double lastWrite; | 322 double lastWrite; |
323 | 323 |
324 // The owner object is the object that the Socket is being used by, e.g. | 324 // The owner object is the object that the Socket is being used by, e.g. |
325 // a HttpServer, a WebSocket connection, a process pipe, etc. | 325 // a HttpServer, a WebSocket connection, a process pipe, etc. |
326 Object owner; | 326 Object owner; |
327 | 327 |
328 static double get timestamp => sw.elapsedMicroseconds / 1000000.0; | 328 static double get timestamp => sw.elapsedMicroseconds / 1000000.0; |
329 | 329 |
330 static Future<List<InternetAddress>> lookup( | 330 static Future<List<InternetAddress>> lookup( |
331 String host, {InternetAddressType type: InternetAddressType.ANY}) { | 331 String host, {InternetAddressType type: InternetAddressType.ANY}) { |
332 return _IOService.dispatch(_SOCKET_LOOKUP, [host, type._value]) | 332 return _IOService._dispatch(_SOCKET_LOOKUP, [host, type._value]) |
333 .then((response) { | 333 .then((response) { |
334 if (isErrorResponse(response)) { | 334 if (isErrorResponse(response)) { |
335 throw createError(response, "Failed host lookup: '$host'"); | 335 throw createError(response, "Failed host lookup: '$host'"); |
336 } else { | 336 } else { |
337 return response.skip(1).map((result) { | 337 return response.skip(1).map((result) { |
338 var type = new InternetAddressType._from(result[0]); | 338 var type = new InternetAddressType._from(result[0]); |
339 return new _InternetAddress(result[1], host, result[2]); | 339 return new _InternetAddress(result[1], host, result[2]); |
340 }).toList(); | 340 }).toList(); |
341 } | 341 } |
342 }); | 342 }); |
343 } | 343 } |
344 | 344 |
345 static Future<InternetAddress> reverseLookup(InternetAddress addr) { | 345 static Future<InternetAddress> reverseLookup(InternetAddress addr) { |
346 return _IOService.dispatch(_SOCKET_REVERSE_LOOKUP, [addr._in_addr]) | 346 return _IOService._dispatch(_SOCKET_REVERSE_LOOKUP, [addr._in_addr]) |
347 .then((response) { | 347 .then((response) { |
348 if (isErrorResponse(response)) { | 348 if (isErrorResponse(response)) { |
349 throw createError(response, "Failed reverse host lookup", addr); | 349 throw createError(response, "Failed reverse host lookup", addr); |
350 } else { | 350 } else { |
351 return addr._cloneWithNewHost(response); | 351 return addr._cloneWithNewHost(response); |
352 } | 352 } |
353 }); | 353 }); |
354 } | 354 } |
355 | 355 |
356 static Future<List<NetworkInterface>> listInterfaces({ | 356 static Future<List<NetworkInterface>> listInterfaces({ |
357 bool includeLoopback: false, | 357 bool includeLoopback: false, |
358 bool includeLinkLocal: false, | 358 bool includeLinkLocal: false, |
359 InternetAddressType type: InternetAddressType.ANY}) { | 359 InternetAddressType type: InternetAddressType.ANY}) { |
360 return _IOService.dispatch(_SOCKET_LIST_INTERFACES, [type._value]) | 360 return _IOService._dispatch(_SOCKET_LIST_INTERFACES, [type._value]) |
361 .then((response) { | 361 .then((response) { |
362 if (isErrorResponse(response)) { | 362 if (isErrorResponse(response)) { |
363 throw createError(response, "Failed listing interfaces"); | 363 throw createError(response, "Failed listing interfaces"); |
364 } else { | 364 } else { |
365 var map = response.skip(1) | 365 var map = response.skip(1) |
366 .fold(new Map<String, NetworkInterface>(), (map, result) { | 366 .fold(new Map<String, NetworkInterface>(), (map, result) { |
367 var type = new InternetAddressType._from(result[0]); | 367 var type = new InternetAddressType._from(result[0]); |
368 var name = result[3]; | 368 var name = result[3]; |
369 var index = result[4]; | 369 var index = result[4]; |
370 var address = new _InternetAddress(result[1], "", result[2]); | 370 var address = new _InternetAddress(result[1], "", result[2]); |
(...skipping 1559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1930 String address, | 1930 String address, |
1931 List<int> in_addr, | 1931 List<int> in_addr, |
1932 int port) { | 1932 int port) { |
1933 return new Datagram( | 1933 return new Datagram( |
1934 data, | 1934 data, |
1935 new _InternetAddress(address, null, in_addr), | 1935 new _InternetAddress(address, null, in_addr), |
1936 port); | 1936 port); |
1937 } | 1937 } |
1938 | 1938 |
1939 String _socketsStats() => _SocketsObservatory.toJSON(); | 1939 String _socketsStats() => _SocketsObservatory.toJSON(); |
OLD | NEW |