← Index
NYTProf Performance Profile   « block view • line view • sub view »
For ddd2.pl
  Run on Tue May 25 16:52:24 2010
Reported on Tue May 25 16:56:45 2010

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