Till Maas <till.m...@till.name> writes:

>> |-       if (!legal_ipv4_port (port))
>> |+       if (port != 0 && !legal_ipv4_port (port))
>
> I am pretty sure that it is possible to listen on port 0, 

not on linux; e.g. see in net/ipv4/inet_connection_sock.c the implementation
of

| /* Obtain a reference to a local port for the given sock,
|  * if snum is zero it means select any available local port.
|  */
| int inet_csk_get_port(struct sock *sk, unsigned short snum)

and its caller.  Windoze seems to have a similar mechanism accordingly
http://msdn.microsoft.com/en-us/library/ms737550%28VS.85%29.aspx

| Binding to a specific port number other than port 0 is discouraged for
| client applications since there is a danger of conflicting with
| another socket already using that port number on the local computer.



RFC 768 states

| Source Port is an optional field ... If not used, a value of zero is
| inserted.

which implies that port 0 is something special which is not to be used
for normal communication.




Enrico

Reply via email to