[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1477314180.7065.108.camel@edumazet-glaptop3.roam.corp.google.com>
Date: Mon, 24 Oct 2016 06:03:00 -0700
From: Eric Dumazet <eric.dumazet@...il.com>
To: Jiri Slaby <jslaby@...e.cz>
Cc: ML netdev <netdev@...r.kernel.org>
Subject: Re: UDP does not autobind on recv
On Mon, 2016-10-24 at 14:54 +0200, Jiri Slaby wrote:
> Hello,
>
> as per man 7 udp:
> In order to receive packets, the socket can be bound to
> a local address first by using bind(2). Otherwise,
> the socket layer will automatically assign a free local
> port out of the range defined by /proc/sys/net/ipv4
> /ip_local_port_range and bind the socket to INADDR_ANY.
>
> I did not know that bind is unneeded, so I tried that. But it does not
> work with this piece of code:
> int main()
> {
> char buf[128];
> int fd = socket(AF_INET, SOCK_DGRAM, 0);
> recv(fd, buf, sizeof(buf), 0);
> }
autobind makes little sense at recv() time really.
How an application could expect to receive a frame to 'some socket'
without even knowing its port ?
How useful would that be exactly ?
How TCP behaves ?
I would say, fix the documentation if it is not correct.
Powered by blists - more mailing lists