$socket = new LWP::Socket; $socket->connect('localhost', 7); # echo $quote = 'I dunno, I dream in Perl sometimes...'; $socket->write("$quote\n"); $socket->read_until("\n", \$buffer); $socket->read(\$buffer); $socket = undef; # close
This class should really not be required, something like this should be part of the standard Perl5 library.
Running this module standalone executes a self test which requires localhost to serve chargen and echo protocols.
$delim
is undefined all data is read. If
$size
is defined, data will be read internally in chunks of
$size
bytes. This does not mean that we will return the data
when size bytes are read.
Note that $delim
is discarded from the data returned.
$size
bytes. Might
return less if the data is available. Dies on timeout.
read().
Can be used if you find out that you have read too
much.
$data
argument might be a scalar or
code.
If data is a reference to a subroutine, then we will call this routine to obtain the data to be written. The routine will be called until it returns undef or empty data. Data might be returned from the callback as a scalar or as a reference to a scalar.
Write returns the number of bytes written to the socket.
name
argument for connect()
or bind().
Might return several addresses in array context if the hostname is bound to several
IP addresses.