Skip to content

Commit

Permalink
test: add a couple of simple programmes to help with testing where we…
Browse files Browse the repository at this point in the history
… want to shove lots of data around
  • Loading branch information
gkc committed Nov 14, 2024
1 parent 13c4568 commit 33de449
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/dart/sshnoports/bin/demo_socket_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ void main(List<String> args) async {
// send a request for N kBytes of data to be sent to us
int numKbsToRequest = int.parse(args[1]);
socket.writeln('$numKbsToRequest');
await socket.flush();

int expected = numKbsToRequest * 1024;
int received = 0;
Expand Down
6 changes: 5 additions & 1 deletion packages/dart/sshnoports/bin/demo_socket_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ void main(List<String> args) async {
server.listen((socket) {
stdout.writeln('New socket connection');
socket.listen((bytes) async {
int numKbsToSend = int.parse(String.fromCharCodes(bytes));
String s = String.fromCharCodes(bytes);
if (s.trim().isEmpty) {
return;
}
int numKbsToSend = int.parse(s);
stdout.writeln('Received request to send $numKbsToSend kBytes');
for (int i = 0; i < numKbsToSend; i++) {
socket.add(kb);
Expand Down

0 comments on commit 33de449

Please sign in to comment.