Search notes:

Perl module IO::Socket

The following simple script does a very basic HTTP request. It takes two arguments: the host and the path:
#!/usr/bin/perl
use warnings;
use strict;

use IO::Socket;

my $host = shift or die; 
my $path = shift or die;

my $socket = IO::Socket::INET->new(
  PeerAddr    => $host,
  PeerPort    =>  80,
  Proto       => 'tcp',
  Timeout     =>  1
)
or die "Could not connect";

print $socket "GET $path HTTP/1.0\x0d\x0a";
print $socket "Host: $host\x0d\x0a";
print $socket "\x0d\x0a";

while (my $line = <$socket>) {
  print $line;
}
Github repository PerlModules, path: /IO/Socket/script.pl

See also

echo server and client with Perl module IO::Socket
Perl modules

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1741108621, '3.138.61.168', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Perl/modules/IO/Socket/index(64): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78