Binding on established (pipe endpoint) ports on Windows
ecki at zusammenkunft.net
Mon Jul 10 22:45:30 UTC 2017
I had the problem in a project that having a number of Pipe Objects (from
the default Windows Selector Provider) produced a range of used TCP ports.
This is somewhat expected (if you accept the fact it uses Sockets for this):
> netstat -nao | findstr 5600
TCP 127.0.0.1:51067 127.0.0.1:51068 HERGESTELLT 5600
TCP 127.0.0.1:51068 127.0.0.1:51067 HERGESTELLT 5600
TCP 127.0.0.1:51069 127.0.0.1:51070 HERGESTELLT 5600
TCP 127.0.0.1:51070 127.0.0.1:51069 HERGESTELLT 5600
Note there are no listening socket. When I now use a ServerSocket/accept on
any of the above ports every second fails - if and only if I bind to
0.0.0.0:x but not 127.0.0.1:x (no matter if reuse is specified or not):
accepting ... ServerSocket[addr=0.0.0.0/0.0.0.0,localport=51067] ok
Failed 51068: java.net.BindException: Address already in use: JVM_Bind
accepting ... ServerSocket[addr=0.0.0.0/0.0.0.0,localport=51069] ok
Failed 51070: java.net.BindException: Address already in use: JVM_Bind
Any idea what is causing this on Windows. I would not expect the bind to
fail on a port from a established socket (but serversocket was closed after
accept as Pipe does).
Tested with Win10 and 8u131 but also seen it with other Windows Versions.
More information about the core-libs-dev