| 1 |
.\" -*- mode: troff; coding: utf-8 -*- |
| 2 |
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) |
| 3 |
.\" |
| 4 |
.\" Standard preamble: |
| 5 |
.\" ======================================================================== |
| 6 |
.de Sp \" Vertical space (when we can't use .PP) |
| 7 |
.if t .sp .5v |
| 8 |
.if n .sp |
| 9 |
.. |
| 10 |
.de Vb \" Begin verbatim text |
| 11 |
.ft CW |
| 12 |
.nf |
| 13 |
.ne \\$1 |
| 14 |
.. |
| 15 |
.de Ve \" End verbatim text |
| 16 |
.ft R |
| 17 |
.fi |
| 18 |
.. |
| 19 |
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. |
| 20 |
.ie n \{\ |
| 21 |
. ds C` "" |
| 22 |
. ds C' "" |
| 23 |
'br\} |
| 24 |
.el\{\ |
| 25 |
. ds C` |
| 26 |
. ds C' |
| 27 |
'br\} |
| 28 |
.\" |
| 29 |
.\" Escape single quotes in literal strings from groff's Unicode transform. |
| 30 |
.ie \n(.g .ds Aq \(aq |
| 31 |
.el .ds Aq ' |
| 32 |
.\" |
| 33 |
.\" If the F register is >0, we'll generate index entries on stderr for |
| 34 |
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index |
| 35 |
.\" entries marked with X<> in POD. Of course, you'll have to process the |
| 36 |
.\" output yourself in some meaningful fashion. |
| 37 |
.\" |
| 38 |
.\" Avoid warning from groff about undefined register 'F'. |
| 39 |
.de IX |
| 40 |
.. |
| 41 |
.nr rF 0 |
| 42 |
.if \n(.g .if rF .nr rF 1 |
| 43 |
.if (\n(rF:(\n(.g==0)) \{\ |
| 44 |
. if \nF \{\ |
| 45 |
. de IX |
| 46 |
. tm Index:\\$1\t\\n%\t"\\$2" |
| 47 |
.. |
| 48 |
. if !\nF==2 \{\ |
| 49 |
. nr % 0 |
| 50 |
. nr F 2 |
| 51 |
. \} |
| 52 |
. \} |
| 53 |
.\} |
| 54 |
.rr rF |
| 55 |
.\" ======================================================================== |
| 56 |
.\" |
| 57 |
.IX Title "IO::Socket::UNIX 3perl" |
| 58 |
.TH IO::Socket::UNIX 3perl 2025-11-16 "perl v5.40.1" "Perl Programmers Reference Guide" |
| 59 |
.\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 60 |
.\" way too many mistakes in technical documents. |
| 61 |
.if n .ad l |
| 62 |
.nh |
| 63 |
.SH NAME |
| 64 |
IO::Socket::UNIX \- Object interface for AF_UNIX domain sockets |
| 65 |
.SH SYNOPSIS |
| 66 |
.IX Header "SYNOPSIS" |
| 67 |
.Vb 1 |
| 68 |
\& use IO::Socket::UNIX; |
| 69 |
\& |
| 70 |
\& my $SOCK_PATH = "$ENV{HOME}/unix\-domain\-socket\-test.sock"; |
| 71 |
\& |
| 72 |
\& # Server: |
| 73 |
\& my $server = IO::Socket::UNIX\->new( |
| 74 |
\& Type => SOCK_STREAM(), |
| 75 |
\& Local => $SOCK_PATH, |
| 76 |
\& Listen => 1, |
| 77 |
\& ); |
| 78 |
\& |
| 79 |
\& my $count = 1; |
| 80 |
\& while (my $conn = $server\->accept()) { |
| 81 |
\& $conn\->print("Hello " . ($count++) . "\en"); |
| 82 |
\& } |
| 83 |
\& |
| 84 |
\& # Client: |
| 85 |
\& my $client = IO::Socket::UNIX\->new( |
| 86 |
\& Type => SOCK_STREAM(), |
| 87 |
\& Peer => $SOCK_PATH, |
| 88 |
\& ); |
| 89 |
\& |
| 90 |
\& # Now read and write from $client |
| 91 |
.Ve |
| 92 |
.SH DESCRIPTION |
| 93 |
.IX Header "DESCRIPTION" |
| 94 |
\&\f(CW\*(C`IO::Socket::UNIX\*(C'\fR provides an object interface to creating and using sockets |
| 95 |
in the AF_UNIX domain. It is built upon the IO::Socket interface and |
| 96 |
inherits all the methods defined by IO::Socket. |
| 97 |
.SH CONSTRUCTOR |
| 98 |
.IX Header "CONSTRUCTOR" |
| 99 |
.IP "new ( [ARGS] )" 4 |
| 100 |
.IX Item "new ( [ARGS] )" |
| 101 |
Creates an \f(CW\*(C`IO::Socket::UNIX\*(C'\fR object, which is a reference to a |
| 102 |
newly created symbol (see the Symbol package). \f(CW\*(C`new\*(C'\fR |
| 103 |
optionally takes arguments, these arguments are in key-value pairs. |
| 104 |
.Sp |
| 105 |
In addition to the key-value pairs accepted by IO::Socket, |
| 106 |
\&\f(CW\*(C`IO::Socket::UNIX\*(C'\fR provides. |
| 107 |
.Sp |
| 108 |
.Vb 4 |
| 109 |
\& Type Type of socket (eg SOCK_STREAM or SOCK_DGRAM) |
| 110 |
\& Local Path to local fifo |
| 111 |
\& Peer Path to peer fifo |
| 112 |
\& Listen Queue size for listen |
| 113 |
.Ve |
| 114 |
.Sp |
| 115 |
If the constructor is only passed a single argument, it is assumed to |
| 116 |
be a \f(CW\*(C`Peer\*(C'\fR specification. |
| 117 |
.Sp |
| 118 |
If the \f(CW\*(C`Listen\*(C'\fR argument is given, but false, the queue size will be set to 5. |
| 119 |
.Sp |
| 120 |
If the constructor fails it will return \f(CW\*(C`undef\*(C'\fR and set the |
| 121 |
\&\f(CW$IO::Socket::errstr\fR package variable to contain an error message. |
| 122 |
.Sp |
| 123 |
.Vb 2 |
| 124 |
\& $sock = IO::Socket::UNIX\->new(...) |
| 125 |
\& or die "Cannot create socket \- $IO::Socket::errstr\en"; |
| 126 |
.Ve |
| 127 |
.Sp |
| 128 |
For legacy reasons the error message is also set into the global \f(CW$@\fR |
| 129 |
variable, and you may still find older code which looks here instead. |
| 130 |
.Sp |
| 131 |
.Vb 2 |
| 132 |
\& $sock = IO::Socket::UNIX\->new(...) |
| 133 |
\& or die "Cannot create socket \- $@\en"; |
| 134 |
.Ve |
| 135 |
.SH METHODS |
| 136 |
.IX Header "METHODS" |
| 137 |
.IP \fBhostpath()\fR 4 |
| 138 |
.IX Item "hostpath()" |
| 139 |
Returns the pathname to the fifo at the local end |
| 140 |
.IP \fBpeerpath()\fR 4 |
| 141 |
.IX Item "peerpath()" |
| 142 |
Returns the pathanme to the fifo at the peer end |
| 143 |
.SH "SEE ALSO" |
| 144 |
.IX Header "SEE ALSO" |
| 145 |
Socket, IO::Socket |
| 146 |
.SH AUTHOR |
| 147 |
.IX Header "AUTHOR" |
| 148 |
Graham Barr. Currently maintained by the Perl Porters. Please report all |
| 149 |
bugs at <https://github.com/Perl/perl5/issues>. |
| 150 |
.SH COPYRIGHT |
| 151 |
.IX Header "COPYRIGHT" |
| 152 |
Copyright (c) 1996\-8 Graham Barr <[email protected]>. All rights reserved. |
| 153 |
This program is free software; you can redistribute it and/or |
| 154 |
modify it under the same terms as Perl itself. |