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.
7 package IO::Socket::UNIX;
15 @ISA = qw(IO::Socket);
17 $VERSION = eval $VERSION;
19 IO::Socket::UNIX->register_domain( AF_UNIX );
23 unshift(@_, "Peer") if @_ == 1;
24 return $class->SUPER::new(@_);
31 my $type = $arg->{Type} || SOCK_STREAM;
33 $sock->socket(AF_UNIX, $type, 0) or
36 if(exists $arg->{Local}) {
37 my $addr = sockaddr_un($arg->{Local});
41 if(exists $arg->{Listen} && $type != SOCK_DGRAM) {
42 $sock->listen($arg->{Listen} || 5) or
45 elsif(exists $arg->{Peer}) {
46 my $addr = sockaddr_un($arg->{Peer});
47 $sock->connect($addr) or
55 @_ == 1 or croak 'usage: $sock->hostpath()';
56 my $n = $_[0]->sockname || return undef;
61 @_ == 1 or croak 'usage: $sock->peerpath()';
62 my $n = $_[0]->peername || return undef;
66 1; # Keep require happy
72 IO::Socket::UNIX - Object interface for AF_UNIX domain sockets
80 C<IO::Socket::UNIX> provides an object interface to creating and using sockets
81 in the AF_UNIX domain. It is built upon the L<IO::Socket> interface and
82 inherits all the methods defined by L<IO::Socket>.
90 Creates an C<IO::Socket::UNIX> object, which is a reference to a
91 newly created symbol (see the C<Symbol> package). C<new>
92 optionally takes arguments, these arguments are in key-value pairs.
94 In addition to the key-value pairs accepted by L<IO::Socket>,
95 C<IO::Socket::UNIX> provides.
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
102 If the constructor is only passed a single argument, it is assumed to
103 be a C<Peer> specification.
106 NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
108 As of VERSION 1.18 all IO::Socket objects have autoflush turned on
109 by default. This was not the case with earlier releases.
111 NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
121 Returns the pathname to the fifo at the local end
125 Returns the pathanme to the fifo at the peer end
131 L<Socket>, L<IO::Socket>
135 Graham Barr. Currently maintained by the Perl Porters. Please report all
136 bugs to <perl5-porters@perl.org>.
140 Copyright (c) 1996-8 Graham Barr <gbarr@pobox.com>. All rights reserved.
141 This program is free software; you can redistribute it and/or
142 modify it under the same terms as Perl itself.