Hi,
I hope somebody can help me with this because I am stumped, what I am trying to do is open a tcp connection to a given port which a game uses, to see if the host is up or down.

This isn't the problem i'm having, the socket is opened, and I am able to detect the status just as I want, the problem is when I want to close the socket connection.

Here is my code to open the socket:

$socket = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $port, Proto => "tcp", Type =>SOCK_STREAM, Timeout => "10") or die "game down\n\n";

And here is what I am using to close:

close($socket);

normally this would work.. however it has been determined that the game does not close it's connection unless it is sent a FIN bit. So if the game was to be open for 4 players and the probe was run 4 times nobody could join, and that is the smaller of the 2 problems, if the host is a Mac, and it is running OS 9 or older the entire computer goes down when they quit their game!

So basically where I am at is that I either need some method of running nmap using nmap -sS -p $port $host from perl, or of coding something that does the equivalent of it.

I apologize in advance if I did not provide enough information, any help would be greatly appreciated.

Thanks


In reply to sockets question by Losk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.