Binding on established (pipe endpoint) ports on Windows

Bernd ecki at
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        HERGESTELLT     5600
  TCP        HERGESTELLT     5600
  TCP        HERGESTELLT     5600
  TCP        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 but not (no matter if reuse is specified or not):

accepting ... ServerSocket[addr=,localport=51067] ok
Failed 51068: Address already in use: JVM_Bind
accepting ... ServerSocket[addr=,localport=51069]  ok
Failed 51070: 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 mailing list