Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FTP: Port numbers.How to?

2 views
Skip to first unread message

Chetan Ahuja

unread,
Jul 29, 1997, 3:00:00 AM7/29/97
to

Hi,
This is a spin-off from my questions on Host-to-Host FTP
thread. I am no networking specialist ( or even a computer scientist)
so there are large gaps in my knowledge.

One thing which is stumping me is this: every time an FTP client
sends a data request to the server, it has to be preceded by a Port
number. Now looking at the output 'ftp -d' I cannot help but notice
that every request is accompanied by a different ( and apparently
arbitrary ) port number. So my question is how does the client allocate
this port number. I presume that it makes calls to the OS which
allocates unique unreserved port numbers available at the time. Is that
correct? If so what are the calls and how are they made to:

1) Unix
2) Win95

I tried to look up Stevens Vol I as that is touted as the Bible of
TCP/IP networking in this forum. But there was no clear answer to this
question in the FTP chapter.

Thanks
Chetan

PS. I will much appreciate an email response. Please remove
the dashes from my email address before sending email. Thanks

Barry Margolin

unread,
Jul 29, 1997, 3:00:00 AM7/29/97
to

In article <33DE6E2F.41C67EA6@saavik.-cem.-msu.-edu>,

Chetan Ahuja <ahuja@saavik.-cem.-msu.-edu> wrote:
> One thing which is stumping me is this: every time an FTP client
>sends a data request to the server, it has to be preceded by a Port
> number. Now looking at the output 'ftp -d' I cannot help but notice
>that every request is accompanied by a different ( and apparently
>arbitrary ) port number. So my question is how does the client allocate
>this port number. I presume that it makes calls to the OS which
>allocates unique unreserved port numbers available at the time. Is that
>correct? If so what are the calls and how are they made to:

When using the sockets API (in most Unix and Windows systems), the
application calls bind(), passing in a sockaddr_in structure whose port
field contains IPPORT_ANY. This requests the OS to assign an unused port
when binding the socket. The application can then call getsockname() to
get the port number that was assigned.

--
Barry Margolin, bar...@bbnplanet.com
BBN Corporation, Cambridge, MA
Support the anti-spam movement; see <http://www.cauce.org/>

0 new messages