Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

How Do I find the Port Number For an Internet Service?

by keiusui (Monk)
on Feb 21, 2006 at 06:22 UTC ( #531625=perlquestion: print w/ replies, xml ) Need Help??
keiusui has asked for the wisdom of the Perl Monks concerning the following question:

Using a Perl script, how would I find out what port number sendmail uses?

2006-02-22 Retitled by g0n, as per Monastery guidelines
Original title: 'port number'

Comment on How Do I find the Port Number For an Internet Service?
Re: How Do I find the Port Number For an Internet Service?
by monarch (Priest) on Feb 21, 2006 at 06:26 UTC
    print `nmap -sS -v -v $hostname` is one way for detecting the port number on a remote system.

    For detecting what is going on in your own system you might want to try print `netstat -ap` and look for what ports sendmail has bound to.

    Assuming you really want to port scan yourself you could try Net::Telnet and try connecting to every port you can and see if you get the introductory SMTP message. Or implement it yourself using IO::Socket::INET.

    Personally I would just try port 25 as a first guess, however.

Re: How Do I find the Port Number For an Internet Service?
by jbrugger (Parson) on Feb 21, 2006 at 06:51 UTC
    monarch is right.
    On your own system you'd could cat /etc/services as root (i'd never do that in a script), but if you've got a proper configured linux like system, certain ports are reserved for proper use, indeed smtp (mail) connects to 25, pop connects to 110 and secure mail connects to 465.
    There are many many more as you probably know. But why do you want to know to how to find out what port number sendmail uses in Perl?

    "We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://531625]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (12)
As of 2014-09-16 12:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (16 votes), past polls