You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
533 B
Perl

#!/usr/bin/perl
use strict;
use Socket;
use constant DEFAULT_ADDR => 'your server';
my $packed_addr = gethostbyname(shift || DEFAULT_ADDR) or die "Can't look up host: $!";
my $protocol = getprotobyname('tcp');
my $port = getservbyname('daytime','tcp') or die "Can't look up port: $!";
my $destination = sockaddr_in($port,$packed_addr);
socket(SOCK,PF_INET,SOCK_STREAM,$protocol) or die "Can't make socket: $!";
connect(SOCK,$destination) or die "Can't connect: $!";
print <SOCK>;