| Filename | /usr/lib/perl/5.18/IO/Socket/UNIX.pm |
| Statements | Executed 12 statements in 333µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 11µs | 22µs | IO::Socket::UNIX::BEGIN@9 |
| 1 | 1 | 1 | 6µs | 554µs | IO::Socket::UNIX::BEGIN@11 |
| 1 | 1 | 1 | 6µs | 36µs | IO::Socket::UNIX::BEGIN@12 |
| 0 | 0 | 0 | 0s | 0s | IO::Socket::UNIX::configure |
| 0 | 0 | 0 | 0s | 0s | IO::Socket::UNIX::hostpath |
| 0 | 0 | 0 | 0s | 0s | IO::Socket::UNIX::new |
| 0 | 0 | 0 | 0s | 0s | IO::Socket::UNIX::peerpath |
| 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 | 2 | 33µs | 2 | 34µs | # spent 22µs (11+11) within IO::Socket::UNIX::BEGIN@9 which was called:
# once (11µs+11µs) by IO::Socket::INET::BEGIN@11 at line 9 # spent 22µs making 1 call to IO::Socket::UNIX::BEGIN@9
# spent 12µs making 1 call to strict::import |
| 10 | 1 | 300ns | our(@ISA, $VERSION); | ||
| 11 | 2 | 26µs | 2 | 1.10ms | # spent 554µs (6+548) within IO::Socket::UNIX::BEGIN@11 which was called:
# once (6µs+548µs) by IO::Socket::INET::BEGIN@11 at line 11 # spent 554µs making 1 call to IO::Socket::UNIX::BEGIN@11
# spent 548µs making 1 call to IO::Socket::import |
| 12 | 2 | 249µs | 2 | 66µs | # spent 36µs (6+30) within IO::Socket::UNIX::BEGIN@12 which was called:
# once (6µs+30µs) by IO::Socket::INET::BEGIN@11 at line 12 # spent 36µs making 1 call to IO::Socket::UNIX::BEGIN@12
# spent 30µs making 1 call to Exporter::import |
| 13 | |||||
| 14 | 1 | 6µs | @ISA = qw(IO::Socket); | ||
| 15 | 1 | 300ns | $VERSION = "1.24"; | ||
| 16 | 1 | 10µs | $VERSION = eval $VERSION; # spent 2µs executing statements in string eval | ||
| 17 | |||||
| 18 | 1 | 4µs | 1 | 2µs | IO::Socket::UNIX->register_domain( AF_UNIX ); # spent 2µ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 | 3µs | 1; # Keep require happy | ||
| 66 | |||||
| 67 | __END__ |