Skip to content

Commit a311f4d

Browse files
authored
Ensure port in listenany stays UInt16 (#47213)
As reported [here](https://discourse.julialang.org/t/test-failures-for-sockets-base-runtests-sockets/88898). My guess on the original issue reported is that, for some reason, the host where the tests are run is unable to listen on any ports, so we end up cycling through the entire UInt16 range (the test starts at port 11011), but when we fail on port 65535, we do `addr.port + 1` and instead of wrapping around as I believe this function intends to happen (as noted by the `addr.port == default_port` check before we error), it gets promoted to `Int(65536)` which then throws an (unexpected) error in the `InetAddr` constructor. I'm not quite sure how to test this exactly though, because we'd need to simulate not being able to listen on any ports? If anyone has any ideas, I'm all ears.
1 parent 0d52506 commit a311f4d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

stdlib/Sockets/src/Sockets.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ function listenany(host::IPAddr, default_port; backlog::Integer=BACKLOG_DEFAULT)
727727
return (addr.port, sock)
728728
end
729729
close(sock)
730-
addr = InetAddr(addr.host, addr.port + 1)
730+
addr = InetAddr(addr.host, addr.port + UInt16(1))
731731
if addr.port == default_port
732732
error("no ports available")
733733
end

0 commit comments

Comments
 (0)