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 // Echo server test program to test socket streams. | 5 // Echo server test program to test socket streams. |
6 // | 6 // |
7 // VMOptions= | 7 // VMOptions= |
8 // VMOptions=--short_socket_read | 8 // VMOptions=--short_socket_read |
9 // VMOptions=--short_socket_write | 9 // VMOptions=--short_socket_write |
10 // VMOptions=--short_socket_read --short_socket_write | 10 // VMOptions=--short_socket_read --short_socket_write |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 Expect.equals(MSGSIZE, offset); | 50 Expect.equals(MSGSIZE, offset); |
51 _messages++; | 51 _messages++; |
52 if (_messages < MESSAGES) { | 52 if (_messages < MESSAGES) { |
53 sendData(); | 53 sendData(); |
54 } else { | 54 } else { |
55 shutdown(); | 55 shutdown(); |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 void errorHandler(e) { | 59 void errorHandler(e) { |
60 Expect.fail("Socket error $e"); | 60 String msg = "Socket error $e"; |
| 61 var trace = getAttachedStackTrace(e); |
| 62 if (trace != null) msg += "\nStackTrace: $trace"; |
| 63 Expect.fail(msg); |
61 } | 64 } |
62 | 65 |
63 void connectHandler() { | 66 void connectHandler() { |
64 _socket.listen(onData, | 67 _socket.listen(onData, |
65 onError: errorHandler, | 68 onError: errorHandler, |
66 onDone: onClosed); | 69 onDone: onClosed); |
67 _socket.add(_buffer); | 70 _socket.add(_buffer); |
68 _socket.close(); | 71 _socket.close(); |
69 data = new List<int>(MSGSIZE); | 72 data = new List<int>(MSGSIZE); |
70 } | 73 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 Expect.equals(EchoServerGame.FIRSTCHAR + i, buffer[i]); | 124 Expect.equals(EchoServerGame.FIRSTCHAR + i, buffer[i]); |
122 } | 125 } |
123 if (offset == MSGSIZE) { | 126 if (offset == MSGSIZE) { |
124 connection.add(buffer); | 127 connection.add(buffer); |
125 connection.close(); | 128 connection.close(); |
126 } | 129 } |
127 } | 130 } |
128 } | 131 } |
129 | 132 |
130 void errorHandler(e) { | 133 void errorHandler(e) { |
131 Expect.fail("Socket error $e"); | 134 String msg = "Socket error $e"; |
| 135 var trace = getAttachedStackTrace(e); |
| 136 if (trace != null) msg += "\nStackTrace: $trace"; |
| 137 Expect.fail(msg); |
132 } | 138 } |
133 | 139 |
134 connection.listen(dataReceived, onError: errorHandler); | 140 connection.listen(dataReceived, onError: errorHandler); |
135 } | 141 } |
136 } | 142 } |
137 | 143 |
138 main() { | 144 main() { |
139 EchoServerGame echoServerGame = new EchoServerGame.start(); | 145 EchoServerGame echoServerGame = new EchoServerGame.start(); |
140 } | 146 } |
OLD | NEW |