@node Net/Cmd, Net/Domain, NNML/Server, Module List
@unnumbered Network Command class (as used by FTP, SMTP etc)


@unnumberedsec NAME

Net::Cmd - Network Command class (as used by FTP, SMTP etc)

@unnumberedsec SYNOPSIS

@example
use Net::Cmd;

@@ISA = qw(Net::Cmd);
@end example

@unnumberedsec DESCRIPTION

@code{Net::Cmd} is a collection of methods that can be inherited by a sub class
of @code{IO::Handle}. These methods implement the functionality required for a
command based protocol, for example FTP and SMTP.

@unnumberedsec USER METHODS

These methods provide a user interface to the @code{Net::Cmd} object.

@table @asis
@item debug ( VALUE )
Set the level of debug information for this object. If @code{VALUE} is not given
then the current state is returned. Otherwise the state is changed to 
@code{VALUE} and the previous state returned. If @code{VALUE} is undef then
the debug level will be set to the default debug level for the class.

This method can also be called as a static method to set/get the default
debug level for a given class.

@item message ()
Returns the text message returned from the last command

@item code ()
Returns the 3-digit code from the last command. If a command is pending
then the value 0 is returned

@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.

@item status ()
Returns the most significant digit of the current status code. If a command
is pending then @code{CMD_PENDING} is returned.

@item datasend ( DATA )
Send data to the remote server, delimiting lines with CRLF. Any lin starting
with a @'.@' will be prefixed with another @'.@'.

@item dataend ()
End the sending of data to the remote server. This is done by ensureing that
the data already sent ends with CRLF then sending @'.CRLF@' to end the
transmission. Once this data has been sent dataend calls @code{response} and
returns true if @code{response} returns CMD_OK.

@end table
@unnumberedsec CLASS METHODS

These methods are not intended to be called by the user, but used or 
over-ridden by a sub-class of @code{Net::Cmd}

@table @asis
@item debug_print ( DIR, TEXT )
Print debugging information. DIR denotes the direction @emph{true} being
data being sent to the server. Calls debug_text before printing to
STDERR.

@item debug_text ( TEXT )
This method is called to print debugging information. TEXT is
the text being sent. The method should return the text to be printed

This is primarily meant for the use of modules such as FTP where passwords
are sent, but we do not want to display them in the debugging information.

@item command ( CMD [, ARGS, ... ])
Send a command to the command server. All arguments a first joined with
a space character and CRLF is appended, this string is then sent to the
command server.

Returns undef upon failure

@item unsupported ()
Sets the status code to 580 and the response text to @'Unsupported command@'.
Returns zero.

@item responce ()
Obtain a responce from the server. Upon success the most significant digit
of the status code is returned. Upon failure, timeout etc., undef is
returned.

@item parse_response ( TEXT )
This method is called by @code{response} 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.

@item getline ()
Retreive one line, delimited by CRLF, from the remote server. Returns undef
upon failure.

NOTE: If you do use this method for any reason, please remember to add
some debug_print calls into your method.

@item ungetline ( TEXT )
Unget a line of text from the server.

@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.

Returns a reference to a list containing the lines, or undef upon failure.

@end table
@unnumberedsec EXPORTS

@code{Net::Cmd} exports six subroutines, five of these, @code{CMD_INFO}, @code{CMD_OK},
@code{CMD_MORE}, @code{CMD_REJECT} and @code{CMD_ERROR} ,correspond to possible results
of @code{response} and status. The sixth is @code{CMD_PENDING}.

@unnumberedsec AUTHOR

Graham Barr <Graham.Barr@@tiuk.ti.com>

@unnumberedsec REVISION

$Revision: 2.2 $

@unnumberedsec COPYRIGHT

Copyright (c) 1995 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.

