Quick and easy way to check a port

D

Derek Fountain

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?
 
J

Josef Moellers

Derek said:
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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top