line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# IO::Socket::UNIX.pm |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Copyright (c) 1997-8 Graham Barr . All rights reserved. |
4
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or |
5
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package IO::Socket::UNIX; |
8
|
|
|
|
|
|
|
|
9
|
17
|
|
|
17
|
|
102
|
use strict; |
|
17
|
|
|
|
|
30
|
|
|
17
|
|
|
|
|
452
|
|
10
|
17
|
|
|
17
|
|
68
|
use IO::Socket; |
|
17
|
|
|
|
|
25
|
|
|
17
|
|
|
|
|
77
|
|
11
|
17
|
|
|
17
|
|
114
|
use Carp; |
|
17
|
|
|
|
|
28
|
|
|
17
|
|
|
|
|
6680
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @ISA = qw(IO::Socket); |
14
|
|
|
|
|
|
|
our $VERSION = "1.49"; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
IO::Socket::UNIX->register_domain( AF_UNIX ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new { |
19
|
9
|
|
|
9
|
1
|
1576019
|
my $class = shift; |
20
|
9
|
50
|
|
|
|
88
|
unshift(@_, "Peer") if @_ == 1; |
21
|
9
|
|
|
|
|
145
|
return $class->SUPER::new(@_); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub configure { |
25
|
7
|
|
|
7
|
0
|
21
|
my($sock,$arg) = @_; |
26
|
7
|
|
|
|
|
17
|
my($bport,$cport); |
27
|
|
|
|
|
|
|
|
28
|
7
|
|
100
|
|
|
72
|
my $type = $arg->{Type} || SOCK_STREAM; |
29
|
|
|
|
|
|
|
|
30
|
7
|
50
|
|
|
|
96
|
$sock->socket(AF_UNIX, $type, 0) or |
31
|
|
|
|
|
|
|
return undef; |
32
|
|
|
|
|
|
|
|
33
|
7
|
50
|
|
|
|
25
|
if(exists $arg->{Blocking}) { |
34
|
0
|
0
|
|
|
|
0
|
$sock->blocking($arg->{Blocking}) or |
35
|
|
|
|
|
|
|
return undef; |
36
|
|
|
|
|
|
|
} |
37
|
7
|
100
|
|
|
|
22
|
if(exists $arg->{Local}) { |
38
|
5
|
|
|
|
|
30
|
my $addr = sockaddr_un($arg->{Local}); |
39
|
5
|
50
|
|
|
|
101
|
$sock->bind($addr) or |
40
|
|
|
|
|
|
|
return undef; |
41
|
|
|
|
|
|
|
} |
42
|
7
|
100
|
66
|
|
|
75
|
if(exists $arg->{Listen} && $type != SOCK_DGRAM) { |
|
|
100
|
|
|
|
|
|
43
|
4
|
50
|
100
|
|
|
34
|
$sock->listen($arg->{Listen} || 5) or |
44
|
|
|
|
|
|
|
return undef; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
elsif(exists $arg->{Peer}) { |
47
|
2
|
|
|
|
|
60
|
my $addr = sockaddr_un($arg->{Peer}); |
48
|
2
|
50
|
|
|
|
246
|
$sock->connect($addr) or |
49
|
|
|
|
|
|
|
return undef; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
7
|
|
|
|
|
103
|
$sock; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub hostpath { |
56
|
0
|
0
|
|
0
|
1
|
|
@_ == 1 or croak 'usage: $sock->hostpath()'; |
57
|
0
|
|
0
|
|
|
|
my $n = $_[0]->sockname || return undef; |
58
|
0
|
|
|
|
|
|
(sockaddr_un($n))[0]; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub peerpath { |
62
|
0
|
0
|
|
0
|
1
|
|
@_ == 1 or croak 'usage: $sock->peerpath()'; |
63
|
0
|
|
0
|
|
|
|
my $n = $_[0]->peername || return undef; |
64
|
0
|
|
|
|
|
|
(sockaddr_un($n))[0]; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; # Keep require happy |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |