Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Code Review: Checking open ports.

by ozone (Friar)
on Jun 09, 2003 at 08:58 UTC ( #264277=note: print w/replies, xml ) Need Help??

in reply to Code Review: Checking open ports.

The way this works, you're not really testing that the services actually are functioning. You're just connecting to the port, which is done at the OS level. So your service could've hung, but as far as you're concerned, it's still alive.

Also, most services have a no-op type function that returns some sort of standard string you can test for. With SMTP, you could 'say hello' by sending 'HELO bob', and expect to get a response. I can't remember the other ones.

Replies are listed 'Best First'.
Re: Re: Code Review: Checking open ports.
by waswas-fng (Curate) on Jun 09, 2003 at 11:30 UTC
    Ozone is right, connecting to the port only verifies there is a program that is listening and bound to the port and acepting incoming connections. If your envornment normally sees crashes of those services where they server fine unless they are not running at all this may be "enough" for you. else more active tests are needed and you either need to understand the protocols that you are testing or use off the shelf modules to test functionality such as lwp for HTTP, net::ftp for FTP etc. note that this type of testing usually requires actuall access to the service (user for ftp, access to a web page to download). You need to decide what level of testing makes you comfortable.

Re: Re: Code Review: Checking open ports.
by naChoZ (Curate) on Jun 09, 2003 at 12:15 UTC
    With smtp, helo should elicit a 250 response code, with pop, user postmaster (or other valid login name) should result in a +OK response, and for ftp, a noop should return a 200 response code.


Re: Re: Code Review: Checking open ports.
by fsn (Friar) on Jun 09, 2003 at 11:41 UTC
    You should be aware that at least sendmail servers logs connection that doesn't do anything useful, ie. only a connect and disconnect, or even a connect, HELO, NOOP and a disconnect. So you better get permission from the server administrator, or he might come back and ask you what you are doing and tell you to stop. It happend to me...

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2022-05-22 13:58 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (80 votes). Check out past polls.