Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: netcat in perl

by zentara (Archbishop)
on Mar 21, 2012 at 19:01 UTC ( [id://960846]=note: print w/replies, xml ) Need Help??


in reply to netcat in perl

Here is a start for you. But I believe netcat will tell you if it can't connect. Why not run netcat thru some IPC. Or use a netcat written in Perl, see netcat.pl
#!/usr/bin/perl use IO::Socket; $addr = '192.168.0.1'; $port = '80'; $socket = eval { return IO::Socket::INET->new( Proto => "tcp", PeerAddr => $addr, PeerPort => $port, Reuse => 1, Timeout => 10) or return undef; }; if ($socket) { print "Port open\n"; eval { return $socket->close; }; return 1; } else { print "Port NOT open\n"; return undef; }

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://960846]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-25 13:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found