{
    "mode": "perldoc",
    "parameter": "Net::Cmd",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Net%3A%3ACmd/json",
    "generated": "2026-06-03T04:27:08Z",
    "synopsis": "use Net::Cmd;\n@ISA = qw(Net::Cmd);",
    "sections": {
        "NAME": {
            "content": "Net::Cmd - Network Command class (as used by FTP, SMTP etc)\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Net::Cmd;\n\n@ISA = qw(Net::Cmd);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "\"Net::Cmd\" is a collection of methods that can be inherited by a sub-class of\n\"IO::Socket::INET\". These methods implement the functionality required for a command based\nprotocol, for example FTP and SMTP.\n\nIf your sub-class does not also derive from \"IO::Socket::INET\" or similar (e.g.\n\"IO::Socket::IP\", \"IO::Socket::INET6\" or \"IO::Socket::SSL\") then you must provide the following\nmethods by other means yourself: \"close()\" and \"timeout()\".\n",
            "subsections": [
                {
                    "name": "Public Methods",
                    "content": "These methods provide a user interface to the \"Net::Cmd\" object.\n\n\"debug($level)\"\nSet the level of debug information for this object. If $level is not given then the current\nstate is returned. Otherwise the state is changed to $level and the previous state returned.\n\nDifferent packages may implement different levels of debug but a non-zero value results in\ncopies of all commands and responses also being sent to STDERR.\n\nIf $level is \"undef\" then the debug level will be set to the default debug level for the\nclass.\n\nThis method can also be called as a *static* method to set/get the default debug level for a\ngiven class.\n\n\"message()\"\nReturns the text message returned from the last command. In a scalar context it returns a\nsingle string, in a list context it will return each line as a separate element. (See\n\"PSEUDO RESPONSES\" below.)\n\n\"code()\"\nReturns the 3-digit code from the last command. If a command is pending then the value 0 is\nreturned. (See \"PSEUDO RESPONSES\" below.)\n\n\"ok()\"\nReturns non-zero if the last code value was greater than zero and less than 400. This holds\ntrue for most command servers. Servers where this does not hold may override this method.\n\n\"status()\"\nReturns the most significant digit of the current status code. If a command is pending then\n\"CMDPENDING\" is returned.\n\n\"datasend($data)\"\nSend data to the remote server, converting LF to CRLF. Any line starting with a '.' will be\nprefixed with another '.'. $data may be an array or a reference to an array. The $data\npassed in must be encoded by the caller to octets of whatever encoding is required, e.g. by\nusing the Encode module's \"encode()\" function.\n\n\"dataend()\"\nEnd the sending of data to the remote server. This is done by ensuring that the data already\nsent ends with CRLF then sending '.CRLF' to end the transmission. Once this data has been\nsent \"dataend\" calls \"response\" and returns true if \"response\" returns CMDOK.\n"
                },
                {
                    "name": "Protected Methods",
                    "content": "These methods are not intended to be called by the user, but used or over-ridden by a sub-class\nof \"Net::Cmd\"\n\n\"debugprint($dir, $text)\"\nPrint debugging information. $dir denotes the direction *true* being data being sent to the\nserver. Calls \"debugtext\" before printing to STDERR.\n\n\"debugtext($dir, $text)\"\nThis method is called to print debugging information. $text is the text being sent. The\nmethod should return the text to be printed.\n\nThis is primarily meant for the use of modules such as FTP where passwords are sent, but we\ndo not want to display them in the debugging information.\n\n\"command($cmd[, $args, ... ])\"\nSend a command to the command server. All arguments are first joined with a space character\nand CRLF is appended, this string is then sent to the command server.\n\nReturns undef upon failure.\n\n\"unsupported()\"\nSets the status code to 580 and the response text to 'Unsupported command'. Returns zero.\n\n\"response()\"\nObtain a response from the server. Upon success the most significant digit of the status\ncode is returned. Upon failure, timeout etc., *CMDERROR* is returned.\n\n\"parseresponse($text)\"\nThis method is called by \"response\" as a method with one argument. It should return an array\nof 2 values, the 3-digit status code and a flag which is true when this is part of a\nmulti-line response and this line is not the last.\n\n\"getline()\"\nRetrieve one line, delimited by CRLF, from the remote server. Returns *undef* upon failure.\n\nNOTE: If you do use this method for any reason, please remember to add some \"debugprint\"\ncalls into your method.\n\n\"ungetline($text)\"\nUnget a line of text from the server.\n\n\"rawdatasend($data)\"\nSend data to the remote server without performing any conversions. $data is a scalar. As\nwith \"datasend()\", the $data passed in must be encoded by the caller to octets of whatever\nencoding is required, e.g. by using the Encode module's \"encode()\" function.\n\n\"readuntildot()\"\nRead data from the remote server until a line consisting of a single '.'. Any lines starting\nwith '..' will have one of the '.'s removed.\n\nReturns a reference to a list containing the lines, or *undef* upon failure.\n\n\"tiedfh()\"\nReturns a filehandle tied to the Net::Cmd object. After issuing a command, you may read from\nthis filehandle using read() or <>. The filehandle will return EOF when the final dot is\nencountered. Similarly, you may write to the filehandle in order to send data to the server\nafter issuing a command that expects data to be written.\n\nSee the Net::POP3 and Net::SMTP modules for examples of this.\n"
                },
                {
                    "name": "Pseudo Responses",
                    "content": "Normally the values returned by \"message()\" and \"code()\" are obtained from the remote server,\nbut in a few circumstances, as detailed below, \"Net::Cmd\" will return values that it sets. You\ncan alter this behavior by overriding DEFREPLYCODE() to specify a different default reply\ncode, or overriding one of the specific error handling methods below.\n\nInitial value\nBefore any command has executed or if an unexpected error occurs \"code()\" will return \"421\"\n(temporary connection failure) and \"message()\" will return undef.\n\nConnection closed\nIf the underlying \"IO::Handle\" is closed, or if there are any read or write failures, the\nfile handle will be forced closed, and \"code()\" will return \"421\" (temporary connection\nfailure) and \"message()\" will return \"[$pkg] Connection closed\" (where $pkg is the name of\nthe class that subclassed \"Net::Cmd\"). The setstatusclosed() method can be overridden to\nset a different message (by calling setstatus()) or otherwise trap this error.\n\nTimeout\nIf there is a read or write timeout \"code()\" will return \"421\" (temporary connection\nfailure) and \"message()\" will return \"[$pkg] Timeout\" (where $pkg is the name of the class\nthat subclassed \"Net::Cmd\"). The setstatustimeout() method can be overridden to set a\ndifferent message (by calling setstatus()) or otherwise trap this error.\n"
                }
            ]
        },
        "EXPORTS": {
            "content": "The following symbols are, or can be, exported by this module:\n\nDefault Exports\n\"CMDINFO\", \"CMDOK\", \"CMDMORE\", \"CMDREJECT\", \"CMDERROR\", \"CMDPENDING\".\n\n(These correspond to possible results of \"response()\" and \"status()\".)\n\nOptional Exports\n*None*.\n\nExport Tags\n*None*.\n",
            "subsections": []
        },
        "KNOWN BUGS": {
            "content": "See <https://rt.cpan.org/Dist/Display.html?Status=Active&Queue=libnet>.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Graham Barr <gbarr@pobox.com <mailto:gbarr@pobox.com>>.\n\nSteve Hay <shay@cpan.org <mailto:shay@cpan.org>> is now maintaining libnet as of version\n1.2202.\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright (C) 1995-2006 Graham Barr. All rights reserved.\n\nCopyright (C) 2013-2016, 2020 Steve Hay. All rights reserved.\n",
            "subsections": []
        },
        "LICENCE": {
            "content": "This module is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself, i.e. under the terms of either the GNU General Public License or the Artistic\nLicense, as specified in the LICENCE file.\n",
            "subsections": []
        },
        "VERSION": {
            "content": "Version 3.13\n",
            "subsections": []
        },
        "DATE": {
            "content": "23 Dec 2020\n",
            "subsections": []
        },
        "HISTORY": {
            "content": "See the Changes file.\n",
            "subsections": []
        }
    },
    "summary": "Net::Cmd - Network Command class (as used by FTP, SMTP etc)",
    "flags": [],
    "examples": [],
    "see_also": []
}