tnx very much guys! i really appreciated the help. even though my question was not specific. im really sorry about it. my question shouldve been like this:
In general IO::Socket process (regardless of which socket and what typ
+e of socket to use) what should be the recommended process to detect
+if the remote machines are alive/reachable if you dont want to put a
+DIE command after the IO::Socket::INET->new() process? (of course, to
+ avoid HANG and probably you would have other codes to execute after
+the socket connect process...)
The only thing I thought about at that time was PING. And yes I did forget to check the man pages, sorry for that. heres what i did.:
sub doit
{
$host="$aa.$bb.$cc.$dd";
$port="23";
$fnd="";
$pong=`ping -c 3 $host -v`; #is there really a "-t" option here?
$fnd=($pong=~m/(...)%/gi);
$xcd=$1;
if ($xcd!=100)
{
$remote = IO::Socket::INET -> new (
Proto => "tcp",
PeerAddr => $host,
PeerPort => $port,
Timeout => 1
);
$| = 1;
if ($remote)
{
close $remote;
print "Socket ready...";
}
else
{
print "Try again!";
}
}
}
tnx really a lot for helping me. but i do have one inquiry though. "Is there a way to detect remote machines if they are alive/reachable w/o using NET::Ping and the shell command /sbin/ping?" Hopefully something like a socket command.
thank you very much to all those who helped me. Lovelots and *mwah*, Cherry.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.