[erlang-questions] HTTP requests and the meaning of eaddrinuse

Per Hedeland per@REDACTED
Sat Jan 31 00:16:50 CET 2009

Per Hedeland <per@REDACTED> wrote:
>Checking for this uniqueness may be expensive, which could explain that
>you get this problem "unnecessarily" - the stack may optimistically use
>a local port that isn't actually free, on the assumption that you don't
>normally make all your connections to the same remote address/port, so
>it "should" work out. Except it doesn't when you are doing benchmarks
>and other things that do tons of connections to the same address/port.
>There are ways to tweak things in those cases though

Forgot one that I actually used recently on FreeBSD - it randomizes the
selection of local port to make spoofing harder, and every now and then
a test case that did a bunch of localhost connections would get the
EADDRINUSE. Turning off the randomization (sysctl
net.inet.ip.portrange.randomized 1 -> 0) made it cycle nicely through
the available range => problem solved. A quick check on a Linux 2.6.20
system doesn't show any such randomization nor reveal a way to turn it
on or off, but it may well be there somewhere...


More information about the erlang-questions mailing list