Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

no available ports for this script

Status
Not open for further replies.

neal83

Programmer
Mar 29, 2007
5
GB
I am trying to teach myself network programming in perl and i am at the early stages, one of the first ports that i am trying to connect to on a server is port 13, this port is suppost to provide you with 'daytime' information (basically the time), problem is every server that i try to connect to has the port closed (for various security reasons i think).

i am running activeperl 5.8 on windows xp pro, the error i get is always on the 'connect()' function, that being, it cant connect. i would appreciate it if anyone who new of a daytime service still running could try this script out for me, thanx in advance

here is the script:

#!/perl/bin/perl

use strict;
use Socket;

use constant DEFAULT_ADDR => '127.0.0.1';
use constant PORT => 13;
use constant IPPROTO_TCP => 6;

my $address = shift || DEFAULT_ADDR;
my $packed_addr = inet_aton($address);
my $destination = sockaddr_in(PORT,$packed_addr);

socket(SOCK,PF_INET,SOCK_STREAM,IPPROTO_TCP) or die "Can't make socket: $!";
connect(SOCK,$destination) or die "Can't connect: $!";

print <SOCK>;
 
I set up a simple socket listener on port 13 and you script connect just fine. I don't have anything that actually runs daytime though..
 
many thanks travs69, your a standup guy, at least now i know that the code im righting actually works lol.

cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top