Binding on established (pipe endpoint) ports on Windows
Bernd
ecki at zusammenkunft.net
Mon Jul 10 22:45:30 UTC 2017
Hello,
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):
51067
accepting ... ServerSocket[addr=0.0.0.0/0.0.0.0,localport=51067] ok
51068
Failed 51068: java.net.BindException: Address already in use: JVM_Bind
51069
accepting ... ServerSocket[addr=0.0.0.0/0.0.0.0,localport=51069] ok
51070
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).
Source: https://gist.github.com/ecki/e69bbca3826c838d51d6239901cb681f
Tested with Win10 and 8u131 but also seen it with other Windows Versions.
Gruss
Bernd
More information about the core-libs-dev
mailing list