Quick and easy way to check a port

Discussion in 'Perl Misc' started by Derek Fountain, Jul 29, 2005.

  1. I'm starting up a child process which, after a delay of a few seconds,
    opens a port and waits for data on it. I want my main script - the
    parent - to pause until the child is ready. I don't have access to the
    source for the child, so I figured the best thing to do is wait until
    the port goes ready.

    Only, I'm not sure how to do that. I could system() out to netstat on
    the Linux box I'm working on, but really need something more platform
    independent - it should work on any form of *NIX if possible. Oh, and I
    don't want to upset the child process, which is basically does: listen,
    accept data, close, done.

    Is there some platform independent way of checking a port is open
    without actually trying to open it then closing it on success?
     
    Derek Fountain, Jul 29, 2005
    #1
    1. Advertising

  2. Derek Fountain wrote:
    > I'm starting up a child process which, after a delay of a few seconds,
    > opens a port and waits for data on it. I want my main script - the
    > parent - to pause until the child is ready. I don't have access to the
    > source for the child, so I figured the best thing to do is wait until
    > the port goes ready.
    >
    > Only, I'm not sure how to do that. I could system() out to netstat on
    > the Linux box I'm working on, but really need something more platform
    > independent - it should work on any form of *NIX if possible. Oh, and I
    > don't want to upset the child process, which is basically does: listen,
    > accept data, close, done.
    >
    > Is there some platform independent way of checking a port is open
    > without actually trying to open it then closing it on success?


    Why not try to connect to the port and retry after a suitable period?

    --
    Josef Möllers (Pinguinpfleger bei FSC)
    If failure had no penalty success would not be a prize
    -- T. Pratchett
     
    Josef Moellers, Aug 1, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stephen Toledo-Brown
    Replies:
    1
    Views:
    500
  2. kathy
    Replies:
    3
    Views:
    740
  3. George Mochrie

    easy way to check if a pid is running?

    George Mochrie, Aug 25, 2004, in forum: Ruby
    Replies:
    5
    Views:
    159
    George Mochrie
    Aug 26, 2004
  4. Nate Wiger
    Replies:
    0
    Views:
    83
    Nate Wiger
    Oct 20, 2006
  5. John Smith
    Replies:
    8
    Views:
    177
    David K. Wall
    Sep 26, 2003
Loading...

Share This Page