NAME

IO::Socket::CLI - CLI for IO::Socket::INET6 and IO::Socket::SSL

VERSION

version 0.041

SYNOPSIS

use IO::Socket::CLI;
our @ISA = ("IO::Socket::CLI");

DESCRIPTION

IO::Socket::CLI provides a command-line interface to IO::Socket::INET6 and IO::Socket::SSL.

METHODS

new(...)

Creates a new IO::Socket::CLI object, returning its reference. Has the following options:

HOST

Hostname or IP address. Default is '127.0.0.1'.

PORT

Port of the service. Default is '143'.

SSL

Boolean value for if an SSL connection. Default is 0.

BYE

String server sends when it hangs up. Default is qr'^\* BYE( |\r?$)'.

TIMEOUT

Timeout in seconds for reading from the socket before returning an empty list. Default is 5.

DELAY

Delay in milliseconds between read attempts if nothing is returned. Default is 10.

Boolean value for if to automatically print the server response on "read()". Default is 1.

PREPEND

Boolean value for if to pretend client commands and server responses with "C: " and "S: ", respectively. Default is 1.

DEBUG

Boolean value for if to give verbose debugging info. Default is 0.

read()

Reads the response from the server, returning it as a list. Tries every DELAY milliseconds until TIMEOUT seconds. Optionally prints the response to STDOUT if PRINT_RESPONSE.

response()

Returns the last stored response from the server as a list.

Prints each line of server response to STDOUT, optionally prepending with "S: " if PREPEND.

is_open()

Returns if the server hung up according to the last server response.

send($command)

Sends $command to the server. Optionally echoes $command if PRINT_RESPONSE.

prompt()

Reads command from STDIN and sends it to the server.

command()

Returns last command sent.

Optionally turns PRINT_RESPONSE on/off. Returns value.

prepend(), prepend($boolean)

Optionally turns PREPEND on/off. Returns value.

timeout(), timeout($seconds)

Optionally sets TIMEOUT in seconds. Must be non-negative. Returns value.

delay(), delay($milliseconds)

Optionally sets DELAY in milliseconds. Must be positive. Returns value.

bye(), bye($bye)

Optionally sets BYE. Must be a regexp-like quote: qr/STRING/. Returns value.

debug(), debug($boolean)

Optionally turns debugging info/verbosity on/off. Returns value.

socket()

Returns the underlying socket.

errstr()

Returns errstr() from the socket. Only for SSL - returns undef otherwise.

close()

Closes the socket. Returns true on success. This method needs to be overridden for SSL connections.

BUGS

Does not verify SSL connections. Has not been tried with STARTTLS.

COPYRIGHT AND LICENSE

Copyright (C) 2012-2014 by Ashley Willis <ashley+perl@gitable.org>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.12.4 or, at your option, any later version of Perl 5 you may have available.

SEE ALSO

IO::Socket::INET6

IO::Socket::INET

IO::Socket::SSL

IO::Socket