Monks,
I have a Windows server that has a couple of vital services listening on ports, and I need to make sure they're always around. I don't want to bind to the port, I am happy enough to look at a table of established sockets and check that everything is there.
Were I to backtick a netstat -na -p tcp, I could grovel through the output and look for the established connections on localhost, and ensure that all the ports I'm interested make the roll-call. For instance, if ports 3105 through 3505 are there, everything's groovy:
... TCP 127.0.0.1:3105 127.0.0.1:4317 ESTABLISHED TCP 127.0.0.1:3205 127.0.0.1:4340 ESTABLISHED TCP 127.0.0.1:3305 127.0.0.1:4329 ESTABLISHED TCP 127.0.0.1:3505 127.0.0.1:1974 ESTABLISHED ... lots of other uninteresting lines omitted ...
Before I code up a regexp, I was idly wondering whether there's anything in Win32:: space that will allow to access the underlying information directly. This strikes me as being more elegant, and a shade more efficient to boot (as the server has several thousand sockets open and netstat takes a while to go about its business), rather than scraping netstat. And I'd learn about a new module, which would be a bonus.
• another intruder with the mooring in the heart of the Perl
In reply to Querying established ports on Win32 by grinder
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |