| 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 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 addr._in_addr, | 1065 addr._in_addr, |
| 1066 interfaceAddr == null ? null : interfaceAddr._in_addr, | 1066 interfaceAddr == null ? null : interfaceAddr._in_addr, |
| 1067 interfaceIndex); | 1067 interfaceIndex); |
| 1068 if (result is OSError) throw result; | 1068 if (result is OSError) throw result; |
| 1069 } | 1069 } |
| 1070 | 1070 |
| 1071 String get _serviceTypePath => 'io/sockets'; | 1071 String get _serviceTypePath => 'io/sockets'; |
| 1072 String get _serviceTypeName => 'Socket'; | 1072 String get _serviceTypeName => 'Socket'; |
| 1073 | 1073 |
| 1074 String _JSONKind() { | 1074 String _JSONKind() { |
| 1075 return isListening ? "LISTENING" : | 1075 return isListening ? "Listening" : |
| 1076 isPipe ? "PIPE" : | 1076 isPipe ? "Pipe" : |
| 1077 isInternal ? "INTERNAL" : "NORMAL"; | 1077 isInternal ? "Internal" : "Normal"; |
| 1078 } | 1078 } |
| 1079 | 1079 |
| 1080 Map _toJSONPipe(bool ref) { | 1080 Map _toJSONPipe(bool ref) { |
| 1081 var name; | 1081 var name = 'Anonymous Pipe'; |
| 1082 if (isClosed) { | |
| 1083 name = 'CLOSED PIPE'; | |
| 1084 } else if (isClosedWrite) { | |
| 1085 name = 'READ PIPE'; | |
| 1086 } else if (isClosedRead) { | |
| 1087 name = 'WRITE PIPE'; | |
| 1088 } else { | |
| 1089 name = 'R/W PIPE'; | |
| 1090 } | |
| 1091 var r = { | 1082 var r = { |
| 1092 'id': _servicePath, | 1083 'id': _servicePath, |
| 1093 'type': _serviceType(ref), | 1084 'type': _serviceType(ref), |
| 1094 'name': name, | 1085 'name': name, |
| 1095 'user_name': name, | 1086 'user_name': name, |
| 1096 'kind': _JSONKind(), | 1087 'kind': _JSONKind(), |
| 1097 }; | 1088 }; |
| 1098 if (ref) { | 1089 if (ref) { |
| 1099 return r; | 1090 return r; |
| 1100 } | 1091 } |
| 1092 r['readClosed'] = isClosedRead; |
| 1093 r['writeClosed'] = isClosedWrite; |
| 1094 r['closing'] = isClosing; |
| 1095 r['listening'] = isListening; |
| 1101 r['fd'] = nativeGetSocketId(); | 1096 r['fd'] = nativeGetSocketId(); |
| 1102 if (owner != null) { | 1097 if (owner != null) { |
| 1103 r['owner'] = owner._toJSON(true); | 1098 r['owner'] = owner._toJSON(true); |
| 1104 } | 1099 } |
| 1105 return r; | 1100 return r; |
| 1106 } | 1101 } |
| 1107 | 1102 |
| 1108 Map _toJSONNetwork(bool ref) { | 1103 Map _toJSONNetwork(bool ref) { |
| 1109 var name = '${address.host}:$port'; | 1104 var name = '${address.host}:$port'; |
| 1110 if (isTcp && !isListening) name += " <-> ${remoteAddress.host}:$remotePort"; | 1105 if (isTcp && !isListening) name += " <-> ${remoteAddress.host}:$remotePort"; |
| 1111 var r = { | 1106 var r = { |
| 1112 'id': _servicePath, | 1107 'id': _servicePath, |
| 1113 'type': _serviceType(ref), | 1108 'type': _serviceType(ref), |
| 1114 'name': name, | 1109 'name': name, |
| 1115 'user_name': name, | 1110 'user_name': name, |
| 1116 'kind': _JSONKind(), | 1111 'kind': _JSONKind(), |
| 1117 }; | 1112 }; |
| 1118 if (ref) { | 1113 if (ref) { |
| 1119 return r; | 1114 return r; |
| 1120 } | 1115 } |
| 1121 r['port'] = port; | 1116 var protocol = isTcp ? "TCP" : isUdp ? "UDP" : null; |
| 1122 r['address'] = address.host; | 1117 var localAddress; |
| 1118 var localPort; |
| 1119 var remoteAddress; |
| 1120 var remotePort; |
| 1121 try { |
| 1122 localAddress = address.address; |
| 1123 } catch (e) { } |
| 1124 try { |
| 1125 localPort = port; |
| 1126 } catch (e) { } |
| 1127 try { |
| 1128 remoteAddress = this.remoteAddress.address; |
| 1129 } catch (e) { } |
| 1130 try { |
| 1131 remotePort = remotePort; |
| 1132 } catch (e) { } |
| 1133 r['localAddress'] = localAddress; |
| 1134 r['localPort'] = localPort; |
| 1135 r['remoteAddress'] = remoteAddress; |
| 1136 r['remotePort'] = remotePort; |
| 1137 r['protocol'] = protocol; |
| 1138 r['readClosed'] = isClosedRead; |
| 1139 r['writeClosed'] = isClosedWrite; |
| 1140 r['closing'] = isClosing; |
| 1141 r['listening'] = isListening; |
| 1123 r['fd'] = nativeGetSocketId(); | 1142 r['fd'] = nativeGetSocketId(); |
| 1124 if (owner != null) { | 1143 if (owner != null) { |
| 1125 r['owner'] = owner._toJSON(true); | 1144 r['owner'] = owner._toJSON(true); |
| 1126 } | 1145 } |
| 1127 return r; | 1146 return r; |
| 1128 } | 1147 } |
| 1129 | 1148 |
| 1130 Map _toJSON(bool ref) { | 1149 Map _toJSON(bool ref) { |
| 1131 if (isPipe) { | 1150 if (isPipe) { |
| 1132 return _toJSONPipe(ref); | 1151 return _toJSONPipe(ref); |
| (...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1953 String address, | 1972 String address, |
| 1954 List<int> in_addr, | 1973 List<int> in_addr, |
| 1955 int port) { | 1974 int port) { |
| 1956 return new Datagram( | 1975 return new Datagram( |
| 1957 data, | 1976 data, |
| 1958 new _InternetAddress(address, null, in_addr), | 1977 new _InternetAddress(address, null, in_addr), |
| 1959 port); | 1978 port); |
| 1960 } | 1979 } |
| 1961 | 1980 |
| 1962 String _socketsStats() => _SocketsObservatory.toJSON(); | 1981 String _socketsStats() => _SocketsObservatory.toJSON(); |
| OLD | NEW |