{
    "mode": "perldoc",
    "parameter": "IO::Socket::UNIX",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/IO%3A%3ASocket%3A%3AUNIX/json",
    "generated": "2026-06-17T13:22:24Z",
    "synopsis": "use IO::Socket::UNIX;\nmy $SOCKPATH = \"$ENV{HOME}/unix-domain-socket-test.sock\";\n# Server:\nmy $server = IO::Socket::UNIX->new(\nType => SOCKSTREAM(),\nLocal => $SOCKPATH,\nListen => 1,\n);\nmy $count = 1;\nwhile (my $conn = $server->accept()) {\n$conn->print(\"Hello \" . ($count++) . \"\\n\");\n}\n# Client:\nmy $client = IO::Socket::UNIX->new(\nType => SOCKSTREAM(),\nPeer => $SOCKPATH,\n);\n# Now read and write from $client",
    "sections": {
        "NAME": {
            "content": "IO::Socket::UNIX - Object interface for AFUNIX domain sockets\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use IO::Socket::UNIX;\n\nmy $SOCKPATH = \"$ENV{HOME}/unix-domain-socket-test.sock\";\n\n# Server:\nmy $server = IO::Socket::UNIX->new(\nType => SOCKSTREAM(),\nLocal => $SOCKPATH,\nListen => 1,\n);\n\nmy $count = 1;\nwhile (my $conn = $server->accept()) {\n$conn->print(\"Hello \" . ($count++) . \"\\n\");\n}\n\n# Client:\nmy $client = IO::Socket::UNIX->new(\nType => SOCKSTREAM(),\nPeer => $SOCKPATH,\n);\n\n# Now read and write from $client\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "\"IO::Socket::UNIX\" provides an object interface to creating and using sockets in the AFUNIX\ndomain. It is built upon the IO::Socket interface and inherits all the methods defined by\nIO::Socket.\n",
            "subsections": []
        },
        "CONSTRUCTOR": {
            "content": "new ( [ARGS] )\nCreates an \"IO::Socket::UNIX\" object, which is a reference to a newly created symbol (see\nthe \"Symbol\" package). \"new\" optionally takes arguments, these arguments are in key-value\npairs.\n\nIn addition to the key-value pairs accepted by IO::Socket, \"IO::Socket::UNIX\" provides.\n\nType        Type of socket (eg SOCKSTREAM or SOCKDGRAM)\nLocal       Path to local fifo\nPeer        Path to peer fifo\nListen      Queue size for listen\n\nIf the constructor is only passed a single argument, it is assumed to be a \"Peer\"\nspecification.\n\nIf the \"Listen\" argument is given, but false, the queue size will be set to 5.\n\nIf the constructor fails it will return \"undef\" and set the $IO::Socket::errstr package\nvariable to contain an error message.\n\n$sock = IO::Socket::UNIX->new(...)\nor die \"Cannot create socket - $IO::Socket::errstr\\n\";\n\nFor legacy reasons the error message is also set into the global $@ variable, and you may\nstill find older code which looks here instead.\n\n$sock = IO::Socket::UNIX->new(...)\nor die \"Cannot create socket - $@\\n\";\n",
            "subsections": []
        },
        "METHODS": {
            "content": "",
            "subsections": [
                {
                    "name": "hostpath",
                    "content": "Returns the pathname to the fifo at the local end\n"
                },
                {
                    "name": "peerpath",
                    "content": "Returns the pathanme to the fifo at the peer end\n"
                }
            ]
        },
        "SEE ALSO": {
            "content": "Socket, IO::Socket\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Graham Barr. Currently maintained by the Perl Porters. Please report all bugs to\n<perlbug@perl.org>.\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright (c) 1996-8 Graham Barr <gbarr@pobox.com>. All rights reserved. This program is free\nsoftware; you can redistribute it and/or modify it under the same terms as Perl itself.\n",
            "subsections": []
        }
    },
    "summary": "IO::Socket::UNIX - Object interface for AFUNIX domain sockets",
    "flags": [],
    "examples": [],
    "see_also": []
}