Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by keiusui (Monk)
on Feb 21, 2006 at 06:22 UTC ( [id://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?

Replies are listed 'Best First'.
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.
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-09-20 00:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (25 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.