SSL
NAME
IO::Socket::SSL - interface for SSL connection
SYNOPSIS
use IO::Socket::SSL;
my $ssl = IO::Socket::SSL.new(:host<example.com>, :port(443));
if $ssl.print("GET / HTTP/1.1\r\n\r\n") {
say $ssl.recv;
}
DESCRIPTION
This module provides an interface for SSL connections.
It uses C to setting up the connection so far (hope it will change soon).
METHODS
method new
method new(*%params) returns IO::Socket::SSL
Gets params like:
encoding : connection's encoding
input-line-separator : specifies how lines of input are separated
for client state:
host : host to connect
port : port to connect
for server state:
localhost : host to use for the server
localport : port for the server
listen : create a server and listen for a new incoming connection
certfile : path to a file with certificates
method recv
method recv(IO::Socket::SSL:, Int $n = 1048576, Bool :$bin = False)
Reads $n bytes from the other side (server/client).
Bool :$bin if we want it to return Buf instead of Str.
method print
method print(IO::Socket::SSL:, Str $s)
method send
DEPRECATED. Use `.print` instead
method send(IO::Socket::SSL:, Str $s)
Sends $s to the other side (server/client).
method accept
method accept(IO::Socket::SSL:)
Waits for a new incoming connection and accepts it.
close
method close(IO::Socket::SSL:)
Closes the connection.
SEE ALSO
EXAMPLE
To download sourcecode of e.g. github.com:
use IO::Socket::SSL;
my $ssl = IO::Socket::SSL.new(:host<github.com>, :port(443));
my $content = Buf.new;
$ssl.print("GET /\r\n\r\n");
while my $read = $ssl.recv {
$content ~= $read;
}
say $content;