App-Termcast

 view release on metacpan or  search on metacpan

t/basic.t  view on Meta::CPAN

        close $cwrite;
        close $cread;
        my $sock = IO::Socket::INET->new(LocalAddr => '127.0.0.1',
                                         LocalPort => $port,
                                         Listen    => 1);
        $sock->accept; # signal to the client that the port is available
        syswrite($swrite, 'a');
        my $client = $sock->accept;
        { sysread($sread, my $buf, 1) }
        is(full_read($client),
           "hello test tset\n\e\]499;{\"geometry\":[80,24]}\x07",
           "got the correct login info");
        $client->send("hello, test\n");
        is(full_read($client), "foo");
        syswrite($swrite, 'a');
        sleep 1 while $client->connected;
    },
);

sub full_read {
    my ($fh) = @_;

t/read-write.t  view on Meta::CPAN

        close $cwrite;
        close $cread;
        my $sock = IO::Socket::INET->new(LocalAddr => '127.0.0.1',
                                         LocalPort => $port,
                                         Listen    => 1);
        $sock->accept; # signal to the client that the port is available
        syswrite($swrite, 'a');
        my $client = $sock->accept;
        { sysread($sread, my $buf, 1) }
        is(full_read($client),
           "hello test tset\n\e\]499;{\"geometry\":[80,24]}\x07",
           "got the correct login info");
        $client->send("hello, test\n");

        syswrite($swrite, 'a');
        my $total_out = '';
        while (1) {
            { sysread($sread, my $buf, 1) }
            my $output = full_read($client);
            last unless defined($output) && length($output);
            $total_out .= $output;

t/write-to-termcast.t  view on Meta::CPAN

        my $port = shift;
        close $cwrite;
        close $cread;
        my $sock = IO::Socket::INET->new(LocalAddr => '127.0.0.1',
                                         LocalPort => $port,
                                         Listen    => 1);
        $sock->accept; # signal to the client that the port is available
        syswrite($swrite, 'a');
        my $client = $sock->accept;
        is(full_read($client),
           "hello test tset\n\e\]499;{\"geometry\":[80,24]}\x07",
           "got the correct login info");
        $client->send("hello, test\n");
        { sysread($sread, my $buf, 1) }

        is(full_read($client), "foo");
        syswrite($swrite, 'a');
        sleep 1 while $client->connected;
    },
);



( run in 1.397 second using v1.01-cache-2.11-cpan-88abd93f124 )