Experimental TCP Server node

This commit is contained in:
Sebastian Morr 2020-09-15 09:30:19 +02:00
parent 148b1be477
commit 7df489baf8
6 changed files with 111 additions and 8 deletions
scripts

23
scripts/net-test Executable file
View file

@ -0,0 +1,23 @@
#!/usr/bin/env perl
use IO::Socket;
$socket = IO::Socket::INET->new(PeerAddr => "127.0.0.1",
PeerPort => 6666,
Proto => "tcp",
Type => SOCK_STREAM);
$s = "Hey äöü!";
$socket->send(chr(length($s)));
$socket->send($s);
while(true) {
my $len;
$socket->recv($len, 4);
my $actual_len = unpack("L", $len);
my $s2;
$socket->recv($s2, ord($len));
print($s2);
STDOUT->flush();
}