Profile of /usr/local/lib/perl5/5.10.1/darwin-2level/IO/Socket/UNIX.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For 05.Domain_and_Item.t
Run on Tue May 4 17:21:41 2010
Reported on Tue May 4 17:23:24 2010

File | /usr/local/lib/perl5/5.10.1/darwin-2level/IO/Socket/UNIX.pm
Statements Executed | 15
Statement Execution Time | 381µs

Subroutines — ordered by exclusive time
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 33µs | 37µs | IO::Socket::UNIX::::BEGIN@9IO::Socket::UNIX::BEGIN@9
1 | 1 | 1 | 11µs | 1.24ms | IO::Socket::UNIX::::BEGIN@11IO::Socket::UNIX::BEGIN@11
1 | 1 | 1 | 10µs | 48µs | IO::Socket::UNIX::::BEGIN@12IO::Socket::UNIX::BEGIN@12
0 | 0 | 0 | 0s | 0s | IO::Socket::UNIX::::configureIO::Socket::UNIX::configure
0 | 0 | 0 | 0s | 0s | IO::Socket::UNIX::::hostpathIO::Socket::UNIX::hostpath
0 | 0 | 0 | 0s | 0s | IO::Socket::UNIX::::newIO::Socket::UNIX::new
0 | 0 | 0 | 0s | 0s | IO::Socket::UNIX::::peerpathIO::Socket::UNIX::peerpath

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | # IO::Socket::UNIX.pm
2 |  |  |  |  | #
3 |  |  |  |  | # Copyright (c) 1997-8 Graham Barr <gbarr@pobox.com>. 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 | 3 | 52µs | 2 | 42µs | # spent 37µs (33+4) within IO::Socket::UNIX::BEGIN@9 which was called # once (33µs+4µs) by IO::Socket::INET::BEGIN@11 at line 9 use strict; # spent 37µs making 1 call to IO::Socket::UNIX::BEGIN@9 # spent 4µs making 1 call to strict::import
10 | 1 | 400ns |  |  | our(@ISA, $VERSION);
11 | 3 | 33µs | 2 | 2.48ms | # spent 1.24ms (11µs+1.23) within IO::Socket::UNIX::BEGIN@11 which was called # once (11µs+1.23ms) by IO::Socket::INET::BEGIN@11 at line 11 use IO::Socket; # spent 1.24ms making 1 call to IO::Socket::UNIX::BEGIN@11 # spent 1.23ms making 1 call to IO::Socket::import
12 | 3 | 254µs | 2 | 86µs | # spent 48µs (10+38) within IO::Socket::UNIX::BEGIN@12 which was called # once (10µs+38µs) by IO::Socket::INET::BEGIN@11 at line 12 use Carp; # spent 48µs making 1 call to IO::Socket::UNIX::BEGIN@12 # spent 38µs making 1 call to Exporter::import
13 |  |  |  |  |
14 | 1 | 8µs |  |  | @ISA = qw(IO::Socket);
15 | 1 | 300ns |  |  | $VERSION = "1.23";
16 | 1 | 17µs |  |  | $VERSION = eval $VERSION;
17 |  |  |  |  |
18 | 1 | 4µs | 1 | 3µs | IO::Socket::UNIX->register_domain( AF_UNIX ); # spent 3µs making 1 call to IO::Socket::register_domain
19 |  |  |  |  |
20 |  |  |  |  | sub new {
21 |  |  |  |  | my $class = shift;
22 |  |  |  |  | unshift(@_, "Peer") if @_ == 1;
23 |  |  |  |  | return $class->SUPER::new(@_);
24 |  |  |  |  | }
25 |  |  |  |  |
26 |  |  |  |  | sub configure {
27 |  |  |  |  | my($sock,$arg) = @_;
28 |  |  |  |  | my($bport,$cport);
29 |  |  |  |  |
30 |  |  |  |  | my $type = $arg->{Type} || SOCK_STREAM;
31 |  |  |  |  |
32 |  |  |  |  | $sock->socket(AF_UNIX, $type, 0) or
33 |  |  |  |  | return undef;
34 |  |  |  |  |
35 |  |  |  |  | if(exists $arg->{Local}) {
36 |  |  |  |  | my $addr = sockaddr_un($arg->{Local});
37 |  |  |  |  | $sock->bind($addr) or
38 |  |  |  |  | return undef;
39 |  |  |  |  | }
40 |  |  |  |  | if(exists $arg->{Listen} && $type != SOCK_DGRAM) {
41 |  |  |  |  | $sock->listen($arg->{Listen} || 5) or
42 |  |  |  |  | return undef;
43 |  |  |  |  | }
44 |  |  |  |  | elsif(exists $arg->{Peer}) {
45 |  |  |  |  | my $addr = sockaddr_un($arg->{Peer});
46 |  |  |  |  | $sock->connect($addr) or
47 |  |  |  |  | return undef;
48 |  |  |  |  | }
49 |  |  |  |  |
50 |  |  |  |  | $sock;
51 |  |  |  |  | }
52 |  |  |  |  |
53 |  |  |  |  | sub hostpath {
54 |  |  |  |  | @_ == 1 or croak 'usage: $sock->hostpath()';
55 |  |  |  |  | my $n = $_[0]->sockname || return undef;
56 |  |  |  |  | (sockaddr_un($n))[0];
57 |  |  |  |  | }
58 |  |  |  |  |
59 |  |  |  |  | sub peerpath {
60 |  |  |  |  | @_ == 1 or croak 'usage: $sock->peerpath()';
61 |  |  |  |  | my $n = $_[0]->peername || return undef;
62 |  |  |  |  | (sockaddr_un($n))[0];
63 |  |  |  |  | }
64 |  |  |  |  |
65 | 1 | 12µs |  |  | 1; # Keep require happy
66 |  |  |  |  |
67 |  |  |  |  | __END__
68 |  |  |  |  |
69 |  |  |  |  | =head1 NAME
70 |  |  |  |  |
71 |  |  |  |  | IO::Socket::UNIX - Object interface for AF_UNIX domain sockets
72 |  |  |  |  |
73 |  |  |  |  | =head1 SYNOPSIS
74 |  |  |  |  |
75 |  |  |  |  | use IO::Socket::UNIX;
76 |  |  |  |  |
77 |  |  |  |  | =head1 DESCRIPTION
78 |  |  |  |  |
79 |  |  |  |  | C<IO::Socket::UNIX> provides an object interface to creating and using sockets
80 |  |  |  |  | in the AF_UNIX domain. It is built upon the L<IO::Socket> interface and
81 |  |  |  |  | inherits all the methods defined by L<IO::Socket>.
82 |  |  |  |  |
83 |  |  |  |  | =head1 CONSTRUCTOR
84 |  |  |  |  |
85 |  |  |  |  | =over 4
86 |  |  |  |  |
87 |  |  |  |  | =item new ( [ARGS] )
88 |  |  |  |  |
89 |  |  |  |  | Creates an C<IO::Socket::UNIX> object, which is a reference to a
90 |  |  |  |  | newly created symbol (see the C<Symbol> package). C<new>
91 |  |  |  |  | optionally takes arguments, these arguments are in key-value pairs.
92 |  |  |  |  |
93 |  |  |  |  | In addition to the key-value pairs accepted by L<IO::Socket>,
94 |  |  |  |  | C<IO::Socket::UNIX> provides.
95 |  |  |  |  |
96 |  |  |  |  | Type Type of socket (eg SOCK_STREAM or SOCK_DGRAM)
97 |  |  |  |  | Local Path to local fifo
98 |  |  |  |  | Peer Path to peer fifo
99 |  |  |  |  | Listen Create a listen socket
100 |  |  |  |  |
101 |  |  |  |  | If the constructor is only passed a single argument, it is assumed to
102 |  |  |  |  | be a C<Peer> specification.
103 |  |  |  |  |
104 |  |  |  |  |
105 |  |  |  |  | NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
106 |  |  |  |  |
107 |  |  |  |  | As of VERSION 1.18 all IO::Socket objects have autoflush turned on
108 |  |  |  |  | by default. This was not the case with earlier releases.
109 |  |  |  |  |
110 |  |  |  |  | NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
111 |  |  |  |  |
112 |  |  |  |  | =back
113 |  |  |  |  |
114 |  |  |  |  | =head1 METHODS
115 |  |  |  |  |
116 |  |  |  |  | =over 4
117 |  |  |  |  |
118 |  |  |  |  | =item hostpath()
119 |  |  |  |  |
120 |  |  |  |  | Returns the pathname to the fifo at the local end
121 |  |  |  |  |
122 |  |  |  |  | =item peerpath()
123 |  |  |  |  |
124 |  |  |  |  | Returns the pathanme to the fifo at the peer end
125 |  |  |  |  |
126 |  |  |  |  | =back
127 |  |  |  |  |
128 |  |  |  |  | =head1 SEE ALSO
129 |  |  |  |  |
130 |  |  |  |  | L<Socket>, L<IO::Socket>
131 |  |  |  |  |
132 |  |  |  |  | =head1 AUTHOR
133 |  |  |  |  |
134 |  |  |  |  | Graham Barr. Currently maintained by the Perl Porters. Please report all
135 |  |  |  |  | bugs to <perl5-porters@perl.org>.
136 |  |  |  |  |
137 |  |  |  |  | =head1 COPYRIGHT
138 |  |  |  |  |
139 |  |  |  |  | Copyright (c) 1996-8 Graham Barr <gbarr@pobox.com>. All rights reserved.
140 |  |  |  |  | This program is free software; you can redistribute it and/or
141 |  |  |  |  | modify it under the same terms as Perl itself.
142 |  |  |  |  |
143 |  |  |  |  | =cut