mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Geoffrey Lee <snailtalk@linux-mandrake.com>
To: linux-kernel@vger.kernel.org
Subject: bind()/connect() to port 0 question for tcp/udp
Date: Tue, 30 Jul 2002 23:31:16 +1000	[thread overview]
Message-ID: <20020730133116.GA17743@anakin.wychk.org> (raw)

Hi list,



I want to ask a question:

In sockets, what is the correct behavior when we try to connect() to port 0
for tcp / udp?


It seems that FreeBSD returns EADDRNOTAVAIL, as does Solaris.

So something like this will fail on Solaris and FreeBSD:

[...]
saddr.sin_port = htons(0);
[...]

connect(AF_INET, (struct sockaddr *)&saddr, sizeof(struct sockaddr));


We don't do this however, and Linux will merrily accept a port of 0 in
a connect(), though most probably your connect() wouldn't succeed.

Making it return EADDRNOTAVAIL to user space would be a trivial task, so
I want to ask, is this a buglet in the Linux implementation, or is FreeBSD
and Solaris wrong?



	- G.

                 reply	other threads:[~2002-07-30 13:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020730133116.GA17743@anakin.wychk.org \
    --to=snailtalk@linux-mandrake.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®