LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-11-2004, 10:00 PM   #1
wmcase
Member
 
Registered: Sep 2003
Location: Ottawa, Ontario, Canada
Distribution: Fedora 12
Posts: 57

Rep: Reputation: 15
What's a port ?


Just another learning question.

I know basically what a physical port (socket, plugin) is? But for some reason everything I read goes all metaphorical and mystical after a certain point when explaining how ports for modem's and serial devices work.

Who or what is 'listening' for what at which port numbers and why?

Seriously, I don't expect an answer to the above question, but that represents how I feel after reading any one of the manuals. (eg. LDP, System Admin Guide, Network Admin Guides I and II, modem HOWTO, ISP HOWTO, serial devices HOWTO plus a couple not so good manuals I have).

Everything is easy to follow then all of a sudden it all turns anthropomorphic. Port numbers are given out (by who? -- what program?, the kernel??, to which program?? or driver? or module? Who decides on the specific number? and why? (I have the list of the usual assignments for IBM etc.) but what about the rest. In one manual a short number may be assigned to a port. In the next manual the number is five or six digits. Is there no restrictions?

Who is this mystical guy who 'listens' at the port? I assume some program has opened some electronic gates somewhere so that when the right bit combination flows through/by those bits activate something -- what? I assume that the same electronic gates or group of gates are used for different communication tasks but in different combinations and that the specific combinations are the port numbers our little guy is listening for. Is that true? But then why do the manuals keep warning about too many gates etc. ?

etc. etc. etc.

I have had no problem with FIFO device pipes, or devfs, I know enough about drivers to understand their function in principal, I think I could understand an explanation of how switches might be turned on or off, but for some reason when electricity comes in touch with metal every writer runs. Why?

So, anybody out there; what's a port?

Bill

Last edited by wmcase; 03-11-2004 at 11:35 PM.
 
Old 03-11-2004, 10:43 PM   #2
DrOzz
Senior Member
 
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185

Rep: Reputation: 60
i just scimmed through and went right to the point of your main question, so sorry if you asked anything within that paragraph, but i will just give you some general info ...

first and foremost ports range from 0 - 65534.
the ports 0 - 1023 are called well-known ports since
they represent commonly used services.
also by definition in the simplest terms i guess we can say :
port = the address on a host where an application makes itself
available to incoming data ...
port number = a unique number associated with a process running on a computer.
for example: 23 is the standard port number associated with the Telnet utility.

take a look at your /etc/services file to get a closer look of all kinds of ports and what
service runs on them ..
here is a list of well known TCP ports

Quote:
In TCP/IP and UDP networks, an endpoint to a logical connection. The port number identifies what type of port it is. For example, port 80 is used for HTTP traffic
above is a definition from webopedia.com
 
Old 03-12-2004, 05:09 AM   #3
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
A port is pretty useless without a host to go with it, and the two together equals a socket.

The TCP/IP stack in the kernel handles sockets and ports, and a program can make a call to the kernel to ask for a listening socket of their own. This whole socket/port terminology is actually just a way of making things easy to understand and handle since what it comes down to is memory ranges.

A program, say an FTP server, establishes a listening port by asking the OS for the port it would like - TCP/21 is standard for the FTP command channel. If this is not already used, the OS (the TCP/IP stack in the kernel) will assign a memory range (if not already done) to "port 21" and monitor that space. When an incoming TCP targeted at port 21 arrives it is moved to the assigned memory area. This is what the port actually is - a memory area. Then the data is moved up through the stack to the application layer where it is handed to the FTP server program which had claimed TCP/21.

On Linux and other UNIX-like operating systems you will often see a master daemon of some sort that handles several different types of services and claims several listening sockets. This little daemon examines the data it is sent and invokes the proper application. inetd and xinetd are examples of this sort of master daemon.

Think of ports as mailboxes in a large house with several apartments - mail gets delivered daily to the house (in which everyone has the same address; the old address = host analogy) and then the janitor delivers the mail to the destination mailboxes so that Mrs Anderson gets her mailorder juicer that she had ordered.


Håkan
 
Old 03-12-2004, 07:59 AM   #4
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629

Rep: Reputation: Disabled
Thank you, Håkan for a simple, but good and easy to follow explanation (In particular I liked the mailbox analogy ).
 
Old 03-12-2004, 08:43 AM   #5
wmcase
Member
 
Registered: Sep 2003
Location: Ottawa, Ontario, Canada
Distribution: Fedora 12
Posts: 57

Original Poster
Rep: Reputation: 15
To hw-tph

Thanks Hakan. That was exactly what I wanted to learn. Straight forward simple and non-anthropomorphic. I was beginning to worry about the little guys "listening" in my computer because I hadn't been feeding them.

I have saved a copy of your reply, printed it and put it on top of all my modem and Ethernet info.

Thanks again.
 
Old 03-12-2004, 11:46 AM   #6
Genesee
Member
 
Registered: Dec 2002
Distribution: Slackware
Posts: 927

Rep: Reputation: 30
well wmcase got me to learn a new word - figured I'd share:


Main Entry: an·thro·po·mor·phic
Pronunciation: "an(t)-thr&-p&-'mor-fik
Function: adjective
Etymology: Late Latin anthropomorphus of human form, from Greek anthrOpomorphos, from anthrOp- + -morphos -morphous

1 : described or thought of as having a human form or human attributes <anthropomorphic deities>
2 : ascribing human characteristics to nonhuman things <anthropomorphic supernaturalism>


 
Old 03-12-2004, 01:32 PM   #7
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
I am glad you found my input useful.

Genesee, thank you for clearing that up for me. I had no idea what it meant but it sure did sound educated.


Håkan
 
Old 03-12-2004, 03:35 PM   #8
wmcase
Member
 
Registered: Sep 2003
Location: Ottawa, Ontario, Canada
Distribution: Fedora 12
Posts: 57

Original Poster
Rep: Reputation: 15
Thank you Guys. You made my day.

It did sound educated, didn't it?

Well, it just shows what a 35 year old B.A. can do for you.

Bill
 
Old 03-12-2004, 07:35 PM   #9
mikshaw
LQ Addict
 
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320

Rep: Reputation: 45
The B.A. is 35 years old? That would make you...~57?
 
Old 03-12-2004, 08:30 PM   #10
itsjustme
Senior Member
 
Registered: Mar 2003
Location: Earth
Distribution: Slackware, Ubuntu, Smoothwall
Posts: 1,571

Rep: Reputation: 47
Uh... I liked DrOzz's explanation too.
 
Old 03-13-2004, 01:38 AM   #11
J.W.
LQ Veteran
 
Registered: Mar 2003
Location: Boise, ID
Distribution: Mint
Posts: 6,642

Rep: Reputation: 87
Great thread, and a couple of excellent posts from hw-tph and DrOzz. However, while I understand how the well-known ports over time would have been standardized, what about the ones in the less-often-used upper ranges? In other words, suppose a given process wants to use, say, port 57324, and the memory is assigned, but then another process comes along and attempts to use that same port? How is contention for a single port resolved? What manages the assignment of the ports, or is it just a free-for-all, first-come-first-served type of deal?

To continue the analogy, what would the mailman in this apartment building do if he knew that Mrs. Anderson lived in #203, but he started getting hockey magazines addressed to Colonel Mustard also at #203. (Assume for purposes of this discussion that Mrs. Anderson and Colonel Mustard are not, uh, romantically involved.) -- J.W.
 
Old 03-15-2004, 03:25 AM   #12
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
A port can only be used by one program or process at any given time - it basically is a first come, first served deal like you said. This is a pretty common issue - many Linux distrubutions come with an FTP server and when a new user tries to install the FTP server of her choice the install goes smoothly but the newly installed server won't start, often after giving a couple of more or less weird error messages. The same is also true when people try to upgrade to Apache2 but it cannot start since Apache(1) is listening on port 80 (the standard http port).

The mailman knows that one (and only one) person is the recipant for each mailbox in use. To him, the name of the person is irrelevant - #203 might be Mrs Anderson or Colonel Mustard, he only knows where to deliver the packages. If it's a Mrs Anderson or a Colonel Mustard picking up the package doesn't matter, it's none of his business. Even if the old lady in #203 doesn't want the NHL Enforcer's Weekly (current issue starring Eric Cairns of the Islanders with bloody fists on the cover) she will get it.

To get more technical - actually dealing with the incoming data is up to the application. If an FTP server gets an HTTP request (due to the FTP server listening to the wrong port, or the URL typed into the browser has an incorrect port) it will either respond with an error message or - more likely - just ignore it and not reply at all. This is application-specific.


Håkan
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PLESK [Solution] Change port to 23 (telnet) instead of default port 8443 x5452 Linux - Software 6 05-10-2009 05:58 AM
linux serial port to router console port connection? frankie_fix Linux - General 3 02-26-2007 09:32 PM
Using serial port card(PCMCIA) with IPAQ running Linux, can't find ttyS0 port d2army Linux - Laptop and Netbook 0 11-12-2005 08:07 PM
route locally generated traffic to ip:port to localhost:port maenho Linux - Software 2 03-11-2005 04:08 AM
--destination-ports port[,port[,port...]] KevinGuy Linux - Networking 1 03-16-2004 06:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration