Triggers y monitorización en postgresql
24 de marzo de 2023Acceso a linux con certificado autofirmado
30 de marzo de 2023Cliente:
#!/usr/bin/perl
use IO::Socket::INET;
use strict;
my $name = '192.168.1.33'; #Server IP
my $port = '7890';
my $socket = IO::Socket::INET->new('PeerAddr' => $name,
'PeerPort' => $port,
'Proto' => 'tcp') or die "Can't create socket ($!)\n";
print "Client sending\n";
while (1) {
my $msg = <STDIN>;
print $socket $msg;
}
close $socket
or die "Can't close socket ($!)\n";
Servidor:
#!/usr/bin/perl
use IO::Socket::INET;
use strict;
my $port = "7890";
my $socket = IO::Socket::INET->new('LocalPort' => $port,
'Proto' => 'tcp',
'Listen' => SOMAXCONN)
or die "Can't create socket ($!)\n";
while (my $client = $socket->accept) {
my $name = gethostbyaddr($client->peeraddr, AF_INET);
my $port = $client->peerport;
while (<$client>) {
print "[$name $port] $_";
my @out = `$_`;
print @out;
print $client "$.: @out";
}
close $client
or die "Can't close ($!)\n";
}
die "Can't accept socket ($!)\n";