[lkml]   [2002]   [Jul]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Subjectbind()/connect() to port 0 question for tcp/udp
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.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:22    [W:0.028 / U:5.808 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site