{
    "mode": "perldoc",
    "parameter": "IO::Socket::INET",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/IO%3A%3ASocket%3A%3AINET/json",
    "generated": "2026-06-09T22:55:47Z",
    "synopsis": "use IO::Socket::INET;",
    "sections": {
        "NAME": {
            "content": "IO::Socket::INET - Object interface for AFINET domain sockets\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use IO::Socket::INET;\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "\"IO::Socket::INET\" provides an object interface to creating and using sockets in the AFINET\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::INET\" 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::INET\" provides.\n\nPeerAddr    Remote host address          <hostname>[:<port>]\nPeerHost    Synonym for PeerAddr\nPeerPort    Remote port or service       <service>[(<no>)] | <no>\nLocalAddr   Local host bind address      hostname[:port]\nLocalHost   Synonym for LocalAddr\nLocalPort   Local host bind port         <service>[(<no>)] | <no>\nProto       Protocol name (or number)    \"tcp\" | \"udp\" | ...\nType        Socket type              SOCKSTREAM | SOCKDGRAM | ...\nListen      Queue size for listen\nReuseAddr   Set SOREUSEADDR before binding\nReuse       Set SOREUSEADDR before binding (deprecated,\nprefer ReuseAddr)\nReusePort   Set SOREUSEPORT before binding\nBroadcast   Set SOBROADCAST before binding\nTimeout     Timeout value for various operations\nMultiHomed  Try all addresses for multi-homed hosts\nBlocking    Determine if connection will be blocking mode\n\nIf \"Listen\" is defined then a listen socket is created, else if the socket type, which is\nderived from the protocol, is SOCKSTREAM then connect() is called. If the \"Listen\" argument\nis given, but false, the queue size will be set to 5.\n\nAlthough it is not illegal, the use of \"MultiHomed\" on a socket which is in non-blocking\nmode is of little use. This is because the first connect will never fail with a timeout as\nthe connect call will not block.\n\nThe \"PeerAddr\" can be a hostname or the IP-address on the \"xx.xx.xx.xx\" form. The \"PeerPort\"\ncan be a number or a symbolic service name. The service name might be followed by a number\nin parenthesis which is used if the service is not known by the system. The \"PeerPort\"\nspecification can also be embedded in the \"PeerAddr\" by preceding it with a \":\".\n\nIf \"Proto\" is not given and you specify a symbolic \"PeerPort\" port, then the constructor\nwill try to derive \"Proto\" from the service name. As a last resort \"Proto\" \"tcp\" is assumed.\nThe \"Type\" parameter will be deduced from \"Proto\" if not specified.\n\nIf the constructor is only passed a single argument, it is assumed to be a \"PeerAddr\"\nspecification.\n\nIf \"Blocking\" is set to 0, the connection will be in nonblocking mode. If not specified it\ndefaults to 1 (blocking mode).\n\nExamples:\n\n$sock = IO::Socket::INET->new(PeerAddr => 'www.perl.org',\nPeerPort => 'http(80)',\nProto    => 'tcp');\n\n$sock = IO::Socket::INET->new(PeerAddr => 'localhost:smtp(25)');\n\n$sock = IO::Socket::INET->new(Listen    => 5,\nLocalAddr => 'localhost',\nLocalPort => 9000,\nProto     => 'tcp');\n\n$sock = IO::Socket::INET->new('127.0.0.1:25');\n\n$sock = IO::Socket::INET->new(\nPeerPort  => 9999,\nPeerAddr  => inetntoa(INADDRBROADCAST),\nProto     => udp,\nLocalAddr => 'localhost',\nBroadcast => 1 )\nor die \"Can't bind : $IO::Socket::errstr\\n\";\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::INET->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::INET->new(...)\nor die \"Cannot create socket - $@\\n\";\n\nMETHODS\nsockaddr ()\nReturn the address part of the sockaddr structure for the socket\n\nsockport ()\nReturn the port number that the socket is using on the local host\n\nsockhost ()\nReturn the address part of the sockaddr structure for the socket in a text form xx.xx.xx.xx\n\npeeraddr ()\nReturn the address part of the sockaddr structure for the socket on the peer host\n\npeerport ()\nReturn the port number for the socket on the peer host.\n\npeerhost ()\nReturn the address part of the sockaddr structure for the socket on the peer host in a text\nform xx.xx.xx.xx\n",
            "subsections": []
        },
        "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::INET - Object interface for AFINET domain sockets",
    "flags": [],
    "examples": [],
    "see_also": []
}