Allow setting {buffer, Buffer} socket server option

If `recbuf` is `undefined` then buffer size is set explicitly to the
previous `recbuf` default of 8192.

The recent option `{recbuf, undefined}` to allow sockets to pick up optimal OS
default kernel buffer sizes inadvertently reset Erlang's userland buffer size
to a default value of 1460. This buffer size, due to a longstanding bug in
Erlang http parser, limits the maximum URL line that can be parsed by the
{packet, http} socket option, and so breaks existing code.

For example this shows how recbuf also sets buffer size:

```
> f(), SockInfo = fun(S) -> inet:getopts(S, [recbuf, buffer]) end, {ok, LS} = gen_tcp:listen(0, [{recbuf, 8192}]), LRes = SockInfo(LS).
{ok,[{recbuf,8192},{buffer,8192}]}
```

Not setting recbuf resets buffer size to 1460:

```
f(), SockInfo = fun(S) -> inet:getopts(S, [recbuf, buffer]) end, {ok, LS} = gen_tcp:listen(0, []), LRes = SockInfo(LS).
{ok,[{recbuf,131072},{buffer,1460}]}
```

References:

 https://github.com/apache/couchdb/issues/1810
 http://erlang.org/pipermail/erlang-questions/2011-June/059571.html
 http://erlang.org/doc/man/inet.html#setopts-2
1 file changed