Subject: Re: A simple TCP/socket/port question
To: None <current-users@NetBSD.ORG, vax@linkdead.paranoia.com>
From: Olaf Seibert <rhialto@polder.ubc.kun.nl>
List: current-users
Date: 07/03/1996 18:31:51
VaX#n8 <vax@linkdead.paranoia.com> wrote:
> When a server or inetd forks off an individual process (say, uucpd) to
> deal with a particular client, I vaguely recall reading somewhere that
> although listening for requests is done on a well-known port, when the
> process accepts on the socket, it gets a different, higher-numbered port
> to work on.

This is not the case.

> If this is not the case, how does the kernel distinguish messages going to
> different uucpd's (or, if uucp is a bad example, ftpd command channels)
> running simultaneously?

TCP distinguishes different connections by the 4-tuple (my-ip-adress,
my-tcp-port-number, other-ip-address, other-tcp-port-number). As
long as any of those numbers differs, it is a different connection.

In the general case when connecting to some server on a well-known port,
the source tcp port numbers differ, because each system makes sure that
for active sockets ("outgoing" connections) each one has a different
port.

> I feel like I'm missing something *really* basic here.

I won't answer that one! ;-)

-Olaf, ignoring SO_REUSEADDR.
--
___ Olaf 'Rhialto' Seibert      D787B44DFC896063 4CBB95A5BD1DAA96 
\X/ Ceci n'est pas un Magritte          rhialto@polder.ubc.kun.nl