| 1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # IO::Socket.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # Copyright (c) 1997-8 Graham Barr <gbarr@pobox.com>. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # This program is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | package IO::Socket; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use 5.008_001; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 5 | ▶ | use IO::Handle; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 5 | ▶ | use Socket 1.3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 5 | ▶ | use Exporter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 5 | ▶ | use Errno; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # legacy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 5 | require IO::Socket::INET; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 5 | ▶ | require IO::Socket::UNIX if ($^O ne 'epoc' && $^O ne 'symbian'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$^O ne "epoc" and $^O ne "symbian"
MC/DC0%0/2
$^O ne "epoc" and $^O ne "symbian"
$^O ne "epoc"
$^O ne "symbian"
Truth table33%1/3
A and B
A= $^O ne "epoc"B= $^O ne "symbian"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 5 | our @ISA = qw(IO::Handle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 5 | our $VERSION = "1.56"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 5 | our @EXPORT_OK = qw(sockatmark); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 5 | our $errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 15 | ▶ | sub import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=3 SCAR=11.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 15 | my $pkg = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 15 | ▶ | if (@_ && $_[0] eq 'sockatmark') { # not very extensible but for now, fast | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ and $_[0] eq "sockatmark"
MC/DC0%0/2
@_ and $_[0] eq "sockatmark"
@_
$_[0] eq "sockatmark"
Truth table66%2/3
A and B
A= @_B= $_[0] eq "sockatmark"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | Exporter::export_to_level('IO::Socket', 1, $pkg, 'sockatmark'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 15 | my $callpkg = caller; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 15 | Exporter::export 'Socket', $callpkg, @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my($class,%arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my $sock = $class->SUPER::new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $sock->autoflush(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ${*$sock}{'io_socket_timeout'} = delete $arg{Timeout}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | return scalar(%arg) ? $sock->configure(\%arg) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | : $sock; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 5 | my @domain2pkg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 10 | ▶ | sub register_domain { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register_domain: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 10 | my($p,$d) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 10 | $domain2pkg[$d] = $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | sub configure { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
configure: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my($sock,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my $domain = delete $arg->{Domain}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | croak 'IO::Socket: Cannot configure a generic socket' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | unless defined $domain; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | croak "IO::Socket: Unsupported socket domain" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | unless defined $domain2pkg[$domain]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | croak "IO::Socket: Cannot configure socket in domain '$domain'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | unless ref($sock) eq "IO::Socket"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | bless($sock, $domain2pkg[$domain]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | $sock->configure($arg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub socket { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
socket: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | @_ == 4 or croak 'usage: $sock->socket(DOMAIN, TYPE, PROTOCOL)'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my($sock,$domain,$type,$protocol) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | socket($sock,$domain,$type,$protocol) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ${*$sock}{'io_socket_domain'} = $domain; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ${*$sock}{'io_socket_type'} = $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # "A value of 0 for protocol will let the system select an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # appropriate protocol" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # so we need to look up what the system selected, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # not cache PF_UNSPEC. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | ${*$sock}{'io_socket_proto'} = $protocol if $protocol; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | $sock; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | sub socketpair { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
socketpair: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | @_ == 4 || croak 'usage: IO::Socket->socketpair(DOMAIN, TYPE, PROTOCOL)'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | my($class,$domain,$type,$protocol) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my $sock1 = $class->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | my $sock2 = $class->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | socketpair($sock1,$sock2,$domain,$type,$protocol) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | return (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ${*$sock1}{'io_socket_type'} = ${*$sock2}{'io_socket_type'} = $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ${*$sock1}{'io_socket_proto'} = ${*$sock2}{'io_socket_proto'} = $protocol; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ($sock1,$sock2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | sub connect { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
connect: not called CC=22 SCAR=62.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | @_ == 2 or croak 'usage: $sock->connect(NAME)'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my $sock = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my $addr = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my $timeout = ${*$sock}{'io_socket_timeout'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | my $blocking; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | $blocking = $sock->blocking(0) if $timeout; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | if (!connect($sock, $addr)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | if (defined $timeout && ($!{EINPROGRESS} || $!{EWOULDBLOCK})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
defined $timeout and $!{"EINPROGRESS"} || $!{"EWOULDBLOCK"}
$!{"EINPROGRESS"} or $!{"EWOULDBLOCK"}
MC/DC0%0/3
defined $timeout and $!{"EINPROGRESS"} || $!{"EWOULDBLOCK"}
defined $timeout
$!{"EINPROGRESS"}
$!{"EWOULDBLOCK"}
Truth table0%0/4
A and B or C
A= defined $timeoutB= $!{"EINPROGRESS"}C= $!{"EWOULDBLOCK"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | require IO::Select; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | my $sel = IO::Select->new( $sock ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | undef $!; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | my($r,$w,$e) = IO::Select::select(undef,$sel,$sel,$timeout); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | if(@$e[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # Windows return from select after the timeout in case of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | # WSAECONNREFUSED(10061) if exception set is not used. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | # This behavior is different from Linux. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # Using the exception | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | # set we now emulate the behavior in Linux | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | # - Karthik Rajagopalan | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $err = $sock->getsockopt(SOL_SOCKET,SO_ERROR); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $errstr = $@ = "connect: $err"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | elsif(!@$w[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | $err = $! || (exists &Errno::ETIMEDOUT ? &Errno::ETIMEDOUT : 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$! || (exists &Errno::ETIMEDOUT ? &Errno::ETIMEDOUT : 1)
MC/DC0%0/2
$! || (exists &Errno::ETIMEDOUT ? &Errno::ETIMEDOUT : 1)
$!
(exists &Errno::ETIMEDOUT ? &Errno::ETIMEDOUT : 1)
Truth table0%0/3
A || B
A= $!B= (exists &Errno::ETIMEDOUT ? &Errno::ETIMEDOUT : 1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | $errstr = $@ = "connect: timeout"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | ▶ | elsif (!connect($sock,$addr) && | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
CORE::connect($sock, $addr) || ($!{'EISCONN'} || $^O eq 'MSWin32' && $! == ($] < 5.019004 ? 10022 : 22))
$!{"EISCONN"} or $^O eq "MSWin32" and $! == ($] < "5.019004" ? 10022 : 22)
$^O eq "MSWin32" and $! == ($] < "5.019004" ? 10022 : 22)
MC/DC0%0/4
CORE::connect($sock, $addr) || ($!{'EISCONN'} || $^O eq 'MSWin32' && $! == ($] < 5.019004 ? 10022 : 22))
CORE::connect($sock, $addr)
$!{"EISCONN"}
$^O eq "MSWin32"
$! == ($] < "5.019004" ? 10022 : 22)
Truth table0%0/5
A || B or C and D
A= CORE::connect($sock, $addr)B= $!{"EISCONN"}C= $^O eq "MSWin32"D= $! == ($] < "5.019004" ? 10022 : 22)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | not ($!{EISCONN} || ($^O eq 'MSWin32' && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | ($! == (($] < 5.019004) ? 10022 : Errno::EINVAL)))) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | # Some systems refuse to re-connect() to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | # an already open socket and set errno to EISCONN. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | # Windows sets errno to WSAEINVAL (10022) (pre-5.19.4) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | # EINVAL (22) (5.19.4 onwards). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | $err = $!; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | $errstr = $@ = "connect: $!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | ▶ | elsif ($blocking || !($!{EINPROGRESS} || $!{EWOULDBLOCK})) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$blocking or not $!{"EINPROGRESS"} || $!{"EWOULDBLOCK"}
$!{'EINPROGRESS'} || $!{'EWOULDBLOCK'}
MC/DC0%0/3
$blocking or not $!{"EINPROGRESS"} || $!{"EWOULDBLOCK"}
$blocking
$!{'EINPROGRESS'}
$!{'EWOULDBLOCK'}
Truth table0%0/4
A or not(B || C)
A= $blockingB= $!{'EINPROGRESS'}C= $!{'EWOULDBLOCK'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | $err = $!; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | $errstr = $@ = "connect: $!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | $sock->blocking(1) if $blocking; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | $! = $err if $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | $err ? undef : $sock; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # Enable/disable blocking IO on sockets. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | # Without args return the current status of blocking, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | # with args change the mode as appropriate, returning the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | # old setting, or in case of error during the mode change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | # undef. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | sub blocking { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
blocking: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my $sock = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | return $sock->SUPER::blocking(@_) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$^O ne "MSWin32" and $^O ne "VMS"
MC/DC0%0/2
$^O ne "MSWin32" and $^O ne "VMS"
$^O ne "MSWin32"
$^O ne "VMS"
Truth table0%0/3
A and B
A= $^O ne "MSWin32"B= $^O ne "VMS"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | if $^O ne 'MSWin32' && $^O ne 'VMS'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | # Windows handles blocking differently | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | # http://groups.google.co.uk/group/perl.perl5.porters/browse_thread/thread/b4e2b1d88280ddff/630b667a66e3509f?#630b667a66e3509f | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | # http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/ioctlsocket_2.asp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # 0x8004667e is FIONBIO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | # which is used to set blocking behaviour. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | # NOTE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | # This is a little confusing, the perl keyword for this is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | # 'blocking' but the OS level behaviour is 'non-blocking', probably | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | # because sockets are blocking by default. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | # Therefore internally we have to reverse the semantics. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | my $orig= !${*$sock}{io_sock_nonblocking}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | return $orig unless @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | my $block = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | if ( !$block != !$orig ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | ${*$sock}{io_sock_nonblocking} = $block ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | ioctl($sock, 0x8004667e, pack("L!",${*$sock}{io_sock_nonblocking})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | return $orig; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | sub close { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
close: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | @_ == 1 or croak 'usage: $sock->close()'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my $sock = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ${*$sock}{'io_socket_peername'} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $sock->SUPER::close(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | sub bind { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bind: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | @_ == 2 or croak 'usage: $sock->bind(NAME)'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my $sock = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | my $addr = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | return bind($sock, $addr) ? $sock | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | sub listen { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listen: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | @_ >= 1 && @_ <= 2 or croak 'usage: $sock->listen([QUEUE])'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ >= 1 and @_ <= 2
MC/DC0%0/2
@_ >= 1 and @_ <= 2
@_ >= 1
@_ <= 2
Truth table0%0/3
A and B
A= @_ >= 1B= @_ <= 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | my($sock,$queue) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | $queue = 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$queue and $queue > 0
MC/DC0%0/2
$queue and $queue > 0
$queue
$queue > 0
Truth table0%0/3
A and B
A= $queueB= $queue > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | unless $queue && $queue > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | return listen($sock, $queue) ? $sock | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | sub accept { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
accept: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | @_ == 1 || @_ == 2 or croak 'usage $sock->accept([PKG])'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ == 1 or @_ == 2
MC/DC0%0/2
@_ == 1 or @_ == 2
@_ == 1
@_ == 2
Truth table0%0/3
A or B
A= @_ == 1B= @_ == 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | my $sock = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | my $pkg = shift || $sock; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() || $sock
MC/DC0%0/2
shift() || $sock
shift()
$sock
Truth table0%0/3
A || B
A= shift()B= $sock
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | my $timeout = ${*$sock}{'io_socket_timeout'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | my $new = $pkg->new(Timeout => $timeout); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my $peer = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | if(defined $timeout) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | require IO::Select; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | my $sel = IO::Select->new( $sock ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | unless ($sel->can_read($timeout)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | $errstr = $@ = 'accept: timeout'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | $! = (exists &Errno::ETIMEDOUT ? &Errno::ETIMEDOUT : 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | $peer = accept($new,$sock) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ${*$new}{$_} = ${*$sock}{$_} for qw( io_socket_domain io_socket_type io_socket_proto ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | return wantarray ? ($new, $peer) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | : $new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | sub sockname { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sockname: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | @_ == 1 or croak 'usage: $sock->sockname()'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | getsockname($_[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | sub peername { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
peername: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | @_ == 1 or croak 'usage: $sock->peername()'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | my($sock) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | ${*$sock}{'io_socket_peername'} ||= getpeername($sock); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
do {
*$sock
}->{"io_socket_peername"} ||= getpeername $sock
MC/DC0%0/2
do {
*$sock
}->{"io_socket_peername"} ||= getpeername $sock
do {
*$sock
}->{"io_socket_peername"}
getpeername $sock
Truth table0%0/3
A ||= B
A= do {
*$sock
}->{"io_socket_peername"}B= getpeername $sock
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | sub connected { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
connected: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | @_ == 1 or croak 'usage: $sock->connected()'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my($sock) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | getpeername($sock); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | sub send { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | @_ >= 2 && @_ <= 4 or croak 'usage: $sock->send(BUF, [FLAGS, [TO]])'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ >= 2 and @_ <= 4
MC/DC0%0/2
@_ >= 2 and @_ <= 4
@_ >= 2
@_ <= 4
Truth table0%0/3
A and B
A= @_ >= 2B= @_ <= 4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | my $sock = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | my $flags = $_[2] || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_[2] || 0
MC/DC0%0/1
$_[2] || 0
$_[2]
Truth table0%0/2
A
A= $_[2]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | my $peer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | if ($_[3]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | # the caller explicitly requested a TO, so use it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | # this is non-portable for "connected" UDP sockets | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | $peer = $_[3]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | elsif (!defined getpeername($sock)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | # we're not connected, so we require a peer from somewhere | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | $peer = $sock->peername; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | croak 'send: Cannot determine peer address' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | unless(defined $peer); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | my $r = $peer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | ? send($sock, $_[1], $flags, $peer) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | : send($sock, $_[1], $flags); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | # remember who we send to, if it was successful | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | ${*$sock}{'io_socket_peername'} = $peer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ == 4 and defined $r
MC/DC0%0/2
@_ == 4 and defined $r
@_ == 4
defined $r
Truth table0%0/3
A and B
A= @_ == 4B= defined $r
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | if(@_ == 4 && defined $r); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | sub recv { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
recv: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | @_ == 3 || @_ == 4 or croak 'usage: $sock->recv(BUF, LEN [, FLAGS])'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ == 3 or @_ == 4
MC/DC0%0/2
@_ == 3 or @_ == 4
@_ == 3
@_ == 4
Truth table0%0/3
A or B
A= @_ == 3B= @_ == 4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | my $sock = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | my $len = $_[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | my $flags = $_[3] || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_[3] || 0
MC/DC0%0/1
$_[3] || 0
$_[3]
Truth table0%0/2
A
A= $_[3]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | # remember who we recv'd from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ${*$sock}{'io_socket_peername'} = recv($sock, $_[1]='', $len, $flags); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | sub shutdown { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shutdown: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | @_ == 2 or croak 'usage: $sock->shutdown(HOW)'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my($sock, $how) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ${*$sock}{'io_socket_peername'} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | shutdown($sock, $how); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | sub setsockopt { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setsockopt: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | @_ == 4 or croak '$sock->setsockopt(LEVEL, OPTNAME, OPTVAL)'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | setsockopt($_[0],$_[1],$_[2],$_[3]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 5 | my $intsize = length(pack("i",0)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | sub getsockopt { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getsockopt: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | @_ == 3 or croak '$sock->getsockopt(LEVEL, OPTNAME)'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | my $r = getsockopt($_[0],$_[1],$_[2]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | # Just a guess | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | $r = unpack("i", $r) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $r and length $r == $intsize
MC/DC0%0/2
defined $r and length $r == $intsize
defined $r
length $r == $intsize
Truth table0%0/3
A and B
A= defined $rB= length $r == $intsize
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | if(defined $r && length($r) == $intsize); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | sub sockopt { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sockopt: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | my $sock = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | @_ == 1 ? $sock->getsockopt(SOL_SOCKET,@_) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | : $sock->setsockopt(SOL_SOCKET,@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | sub atmark { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
atmark: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | @_ == 1 or croak 'usage: $sock->atmark()'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | my($sock) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | sockatmark($sock); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | sub timeout { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
timeout: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | @_ == 1 || @_ == 2 or croak 'usage: $sock->timeout([VALUE])'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ == 1 or @_ == 2
MC/DC0%0/2
@_ == 1 or @_ == 2
@_ == 1
@_ == 2
Truth table0%0/3
A or B
A= @_ == 1B= @_ == 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | my($sock,$val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my $r = ${*$sock}{'io_socket_timeout'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | ${*$sock}{'io_socket_timeout'} = defined $val ? 0 + $val : $val | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | if(@_ == 2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | sub sockdomain { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sockdomain: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | @_ == 1 or croak 'usage: $sock->sockdomain()'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | my $sock = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | if (!defined(${*$sock}{'io_socket_domain'})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | my $addr = $sock->sockname(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | ${*$sock}{'io_socket_domain'} = sockaddr_family($addr) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | if (defined($addr)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ${*$sock}{'io_socket_domain'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | sub socktype { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
socktype: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | @_ == 1 or croak 'usage: $sock->socktype()'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | my $sock = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ${*$sock}{'io_socket_type'} = $sock->sockopt(Socket::SO_TYPE) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | if (!defined(${*$sock}{'io_socket_type'}) && defined(eval{Socket::SO_TYPE})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined do {
*$sock
}->{"io_socket_type"} and defined eval {
do {
3
}
}
MC/DC0%0/2
not defined do {
*$sock
}->{"io_socket_type"} and defined eval {
do {
3
}
}
not defined do {
*$sock
}->{"io_socket_type"}
defined eval {
do {
3
}
}
Truth table0%0/3
not(A) and B
A= not defined do {
*$sock
}->{"io_socket_type"}B= defined eval {
do {
3
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ${*$sock}{'io_socket_type'} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | sub protocol { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
protocol: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | @_ == 1 or croak 'usage: $sock->protocol()'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | my($sock) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ${*$sock}{'io_socket_proto'} = $sock->sockopt(Socket::SO_PROTOCOL) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | if (!defined(${*$sock}{'io_socket_proto'}) && defined(eval{Socket::SO_PROTOCOL})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined do {
*$sock
}->{"io_socket_proto"} and defined eval {
do {
38
}
}
MC/DC0%0/2
not defined do {
*$sock
}->{"io_socket_proto"} and defined eval {
do {
38
}
}
not defined do {
*$sock
}->{"io_socket_proto"}
defined eval {
do {
38
}
}
Truth table0%0/3
not(A) and B
A= not defined do {
*$sock
}->{"io_socket_proto"}B= defined eval {
do {
38
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ${*$sock}{'io_socket_proto'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||