Advertisement

04.16.2008 at 03:55PM PDT, ID: 23329217
[x]
Attachment Details

Perl socket needs timeout

Asked by dr34m3rs in Perl Programming Language, Linux

Tags: Perl

Hello experts. I need a timeout for the following code.

Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
#!/usr/bin/perl
 
use Socket;
 
$host = "0.0.0.0"; # change this to an actual IP address
$port = 85;
 
$error = 0;
socket(SH, PF_INET, SOCK_STREAM, getprotobyname('tcp')) || die $!;
my $sin = sockaddr_in ($port,inet_aton($host));
connect(SH,$sin) or $error = "1";
if($error eq "1")
{
	print "Unable to connect: ".$!."\n";
}
else
{
	print $host." on port ".$port." OPEN\n";
}
 
close(SH) || die $!;
[+][-]04.16.2008 at 09:43PM PDT, ID: 21374232

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Perl Programming Language, Linux
Tags: Perl
Sign Up Now!
Solution Provided By: arnold
Participating Experts: 1
Solution Grade: A
 
 
[+][-]04.17.2008 at 07:24AM PDT, ID: 21377396

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628