| 1 | package Net::FCP::Tiny; | ||||||||||||||||||||
| 2 | 1 | ▶ | BEGIN { | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 1 | $Net::FCP::Tiny::AUTHORITY = 'cpan:AVAR'; | |||||||||||||||||||
| 4 | } | ||||||||||||||||||||
| 5 | 1 | ▶ | BEGIN { | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 1 | $Net::FCP::Tiny::VERSION = '0.03'; | |||||||||||||||||||
| 7 | } | ||||||||||||||||||||
| 8 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 1 | ▶ | use IO::Socket::INET; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 1 | ▶ | use Exporter 'import'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||
| 14 | 0 | my ($pkg, %args) = @_; | |||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 0 | ▶ | $args{name} ||= __PACKAGE__; | ||||||||||||||||||
|
Condition0%0/2
$args{"name"} ||= __PACKAGE__
MC/DC0%0/1
$args{"name"} ||= __PACKAGE__
$args{"name"}
Truth table0%0/2
A
A= $args{"name"}
| |||||||||||||||||||||
| 17 | 0 | ▶ | $args{host} ||= 'localhost'; | ||||||||||||||||||
|
Condition0%0/2
$args{"host"} ||= "localhost"
MC/DC0%0/1
$args{"host"} ||= "localhost"
$args{"host"}
Truth table0%0/2
A
A= $args{"host"}
| |||||||||||||||||||||
| 18 | 0 | ▶ | $args{port} ||= 9481; | ||||||||||||||||||
|
Condition0%0/2
$args{"port"} ||= 9481
MC/DC0%0/1
$args{"port"} ||= 9481
$args{"port"}
Truth table0%0/2
A
A= $args{"port"}
| |||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | $args{sock} ||= IO::Socket::INET->new( | ||||||||||||||||||||
| 21 | PeerAddr => $args{host}, | ||||||||||||||||||||
| 22 | PeerPort => $args{port}, | ||||||||||||||||||||
| 23 | 0 | ▶ | Proto => 'tcp', | ||||||||||||||||||
|
Condition0%0/3
$args{"sock"} ||= "IO::Socket::INET"->new("PeerAddr", $args{"host"}, "PeerPort", $args{"port"}, "Proto", "tcp", "Blocking", 1)
MC/DC0%0/2
$args{"sock"} ||= "IO::Socket::INET"->new("PeerAddr", $args{"host"}, "PeerPort", $args{"port"}, "Proto", "tcp", "Blocking", 1)
$args{"sock"}
"IO::Socket::INET"->new("PeerAddr", $args{"host"}, "PeerPort", $args{"port"}, "Proto", "tcp", "Blocking", 1)
Truth table0%0/3
A ||= B
A= $args{"sock"}B= "IO::Socket::INET"->new("PeerAddr", $args{"host"}, "PeerPort", $args{"port"}, "Proto", "tcp", "Blocking", 1)
| |||||||||||||||||||||
| 24 | Blocking => 1, | ||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | # Couldn't connect | ||||||||||||||||||||
| 28 | 0 | ▶ | return unless $args{sock}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 0 | my $self = bless \%args => $pkg; | |||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 0 | my $helo = $self->send_msg(<<'END'); | |||||||||||||||||||
| 33 | ClientHello | ||||||||||||||||||||
| 34 | Name=$args{$name}; | ||||||||||||||||||||
| 35 | ExpectedVersion=2.0 | ||||||||||||||||||||
| 36 | EndMessage | ||||||||||||||||||||
| 37 | END | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 0 | return $self; | |||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 0 | ▶ | sub send_msg { | ||||||||||||||||||
|
Subroutine
send_msg: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 43 | 0 | my ($self, $msg) = @_; | |||||||||||||||||||
| 44 | 0 | my $sock = $self->{sock}; | |||||||||||||||||||
| 45 | 0 | my @line; | |||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 0 | print $sock $msg; | |||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 0 | ▶ | while (my $line = <$sock>) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 50 | 0 | chomp $line; | |||||||||||||||||||
| 51 | 0 | ▶ | last if $line eq 'EndMessage'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 52 | 0 | push @line => $line; | |||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 0 | return \@line; | |||||||||||||||||||
| 56 | } | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | 0 | ▶ | sub array2hash { | ||||||||||||||||||
|
Subroutine
array2hash: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 59 | 0 | my ($self, $lines) = @_; | |||||||||||||||||||
| 60 | return +{ | ||||||||||||||||||||
| 61 | map { | ||||||||||||||||||||
| 62 | 0 | my ($k, $v) = split(/=/, $_, 2); | |||||||||||||||||||
| 63 | 0 | $k => $v; | |||||||||||||||||||
| 64 | } @$lines | ||||||||||||||||||||
| 65 | }; | ||||||||||||||||||||
| 66 | } | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | 1 | 1; | |||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | __END__ | ||||||||||||||||||||