.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.20)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.ie \nF \{\
.    de IX
.    tm Index:\\$1\t\\n%\t"\\$2"
..
.    nr % 0
.    rr F
.\}
.el \{\
.    de IX
..
.\}
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
.    \" fudge factors for nroff and troff
.if n \{\
.    ds #H 0
.    ds #V .8m
.    ds #F .3m
.    ds #[ \f1
.    ds #] \fP
.\}
.if t \{\
.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
.    ds #V .6m
.    ds #F 0
.    ds #[ \&
.    ds #] \&
.\}
.    \" simple accents for nroff and troff
.if n \{\
.    ds ' \&
.    ds ` \&
.    ds ^ \&
.    ds , \&
.    ds ~ ~
.    ds /
.\}
.if t \{\
.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
.    \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
.    \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
.    \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
.    ds : e
.    ds 8 ss
.    ds o a
.    ds d- d\h'-1'\(ga
.    ds D- D\h'-1'\(hy
.    ds th \o'bp'
.    ds Th \o'LP'
.    ds ae ae
.    ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "Net::Cmd 3pm"
.TH Net::Cmd 3pm "2021-02-02" "perl v5.16.3" "Perl Programmers Reference Guide"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
Net::Cmd \- Network Command class (as used by FTP, SMTP etc)
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\&    use Net::Cmd;
\&
\&    @ISA = qw(Net::Cmd);
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
\&\f(CW\*(C`Net::Cmd\*(C'\fR is a collection of methods that can be inherited by a sub class
of \f(CW\*(C`IO::Handle\*(C'\fR. These methods implement the functionality required for a
command based protocol, for example \s-1FTP\s0 and \s-1SMTP\s0.
.SH "USER METHODS"
.IX Header "USER METHODS"
These methods provide a user interface to the \f(CW\*(C`Net::Cmd\*(C'\fR object.
.IP "debug ( \s-1VALUE\s0 )" 4
.IX Item "debug ( VALUE )"
Set the level of debug information for this object. If \f(CW\*(C`VALUE\*(C'\fR is not given
then the current state is returned. Otherwise the state is changed to 
\&\f(CW\*(C`VALUE\*(C'\fR and the previous state returned.
.Sp
Different packages
may implement different levels of debug but a non-zero value results in 
copies of all commands and responses also being sent to \s-1STDERR\s0.
.Sp
If \f(CW\*(C`VALUE\*(C'\fR is \f(CW\*(C`undef\*(C'\fR then the debug level will be set to the default
debug level for the class.
.Sp
This method can also be called as a \fIstatic\fR method to set/get the default
debug level for a given class.
.IP "message ()" 4
.IX Item "message ()"
Returns the text message returned from the last command
.IP "code ()" 4
.IX Item "code ()"
Returns the 3\-digit code from the last command. If a command is pending
then the value 0 is returned
.IP "ok ()" 4
.IX Item "ok ()"
Returns non-zero if the last code value was greater than zero and
less than 400. This holds true for most command servers. Servers
where this does not hold may override this method.
.IP "status ()" 4
.IX Item "status ()"
Returns the most significant digit of the current status code. If a command
is pending then \f(CW\*(C`CMD_PENDING\*(C'\fR is returned.
.IP "datasend ( \s-1DATA\s0 )" 4
.IX Item "datasend ( DATA )"
Send data to the remote server, converting \s-1LF\s0 to \s-1CRLF\s0. Any line starting
with a '.' will be prefixed with another '.'.
\&\f(CW\*(C`DATA\*(C'\fR may be an array or a reference to an array.
.IP "dataend ()" 4
.IX Item "dataend ()"
End the sending of data to the remote server. This is done by ensuring that
the data already sent ends with \s-1CRLF\s0 then sending '.CRLF' to end the
transmission. Once this data has been sent \f(CW\*(C`dataend\*(C'\fR calls \f(CW\*(C`response\*(C'\fR and
returns true if \f(CW\*(C`response\*(C'\fR returns \s-1CMD_OK\s0.
.SH "CLASS METHODS"
.IX Header "CLASS METHODS"
These methods are not intended to be called by the user, but used or 
over-ridden by a sub-class of \f(CW\*(C`Net::Cmd\*(C'\fR
.IP "debug_print ( \s-1DIR\s0, \s-1TEXT\s0 )" 4
.IX Item "debug_print ( DIR, TEXT )"
Print debugging information. \f(CW\*(C`DIR\*(C'\fR denotes the direction \fItrue\fR being
data being sent to the server. Calls \f(CW\*(C`debug_text\*(C'\fR before printing to
\&\s-1STDERR\s0.
.IP "debug_text ( \s-1TEXT\s0 )" 4
.IX Item "debug_text ( TEXT )"
This method is called to print debugging information. \s-1TEXT\s0 is
the text being sent. The method should return the text to be printed
.Sp
This is primarily meant for the use of modules such as \s-1FTP\s0 where passwords
are sent, but we do not want to display them in the debugging information.
.IP "command ( \s-1CMD\s0 [, \s-1ARGS\s0, ... ])" 4
.IX Item "command ( CMD [, ARGS, ... ])"
Send a command to the command server. All arguments a first joined with
a space character and \s-1CRLF\s0 is appended, this string is then sent to the
command server.
.Sp
Returns undef upon failure
.IP "unsupported ()" 4
.IX Item "unsupported ()"
Sets the status code to 580 and the response text to 'Unsupported command'.
Returns zero.
.IP "response ()" 4
.IX Item "response ()"
Obtain a response from the server. Upon success the most significant digit
of the status code is returned. Upon failure, timeout etc., \fIundef\fR is
returned.
.IP "parse_response ( \s-1TEXT\s0 )" 4
.IX Item "parse_response ( TEXT )"
This method is called by \f(CW\*(C`response\*(C'\fR as a method with one argument. It should
return an array of 2 values, the 3\-digit status code and a flag which is true
when this is part of a multi-line response and this line is not the list.
.IP "getline ()" 4
.IX Item "getline ()"
Retrieve one line, delimited by \s-1CRLF\s0, from the remote server. Returns \fIundef\fR
upon failure.
.Sp
\&\fB\s-1NOTE\s0\fR: If you do use this method for any reason, please remember to add
some \f(CW\*(C`debug_print\*(C'\fR calls into your method.
.IP "ungetline ( \s-1TEXT\s0 )" 4
.IX Item "ungetline ( TEXT )"
Unget a line of text from the server.
.IP "rawdatasend ( \s-1DATA\s0 )" 4
.IX Item "rawdatasend ( DATA )"
Send data to the remote server without performing any conversions. \f(CW\*(C`DATA\*(C'\fR
is a scalar.
.IP "read_until_dot ()" 4
.IX Item "read_until_dot ()"
Read data from the remote server until a line consisting of a single '.'.
Any lines starting with '..' will have one of the '.'s removed.
.Sp
Returns a reference to a list containing the lines, or \fIundef\fR upon failure.
.IP "tied_fh ()" 4
.IX Item "tied_fh ()"
Returns a filehandle tied to the Net::Cmd object.  After issuing a
command, you may read from this filehandle using \fIread()\fR or <>.  The
filehandle will return \s-1EOF\s0 when the final dot is encountered.
Similarly, you may write to the filehandle in order to send data to
the server after issuing a command that expects data to be written.
.Sp
See the Net::POP3 and Net::SMTP modules for examples of this.
.SH "EXPORTS"
.IX Header "EXPORTS"
\&\f(CW\*(C`Net::Cmd\*(C'\fR exports six subroutines, five of these, \f(CW\*(C`CMD_INFO\*(C'\fR, \f(CW\*(C`CMD_OK\*(C'\fR,
\&\f(CW\*(C`CMD_MORE\*(C'\fR, \f(CW\*(C`CMD_REJECT\*(C'\fR and \f(CW\*(C`CMD_ERROR\*(C'\fR, correspond to possible results
of \f(CW\*(C`response\*(C'\fR and \f(CW\*(C`status\*(C'\fR. The sixth is \f(CW\*(C`CMD_PENDING\*(C'\fR.
.SH "AUTHOR"
.IX Header "AUTHOR"
Graham Barr <gbarr@pobox.com>
.SH "COPYRIGHT"
.IX Header "COPYRIGHT"
Copyright (c) 1995\-2006 Graham Barr. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
