use strict; use warnings; use IO::Socket::INET; use IO::Socket::SSL; # auto-flush on socket $| = 1; # create a connecting socket my $socket = new IO::Socket::SSL ( PeerAddr => '192.168.1.59', PeerPort => '7777', Proto => 'tcp', Domain => AF_INET, ); die "cannot connect to the server :$!: :$SSL_ERROR:\n" unless $socket; print "connected to the server\n"; # data to send to a server my $req = 'hello world'; my $size = $socket->send($req); print "sent data of length $size\n"; # notify server that request has been sent shutdown($socket, 1); # receive a response of up to 1024 characters from server my $response = ""; $socket->recv($response, 1024); print "received response: $response\n"; $socket->close();