Stream: helpdesk (published)

Topic: Multiple sockets bound to the same port


view this post on Zulip James Wrigley (Dec 06 2023 at 22:40):

How come this works and doesn't throw an error about the address already being used? :thinking:

julia> versioninfo()
Julia Version 1.10.0-rc2
Commit dbb9c46795b (2023-12-03 15:25 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 12 × Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
  Threads: 1 on 12 virtual cores
Environment:
  LD_LIBRARY_PATH = :/opt/zfp/lib64:/opt/adios2/lib:/usr/lib64/openmpi/lib:/usr/local/lib

julia> import Sockets

julia> x = Sockets.TCPSocket(; delay=false)
Sockets.TCPSocket(RawFD(21) init, 0 bytes waiting)

julia> y = Sockets.TCPSocket(; delay=false)
Sockets.TCPSocket(RawFD(22) init, 0 bytes waiting)

julia> Sockets.bind(x, Sockets.IPv4("127.0.0.1"), 8080; reuseaddr=false)
true

julia> Sockets.bind(y, Sockets.IPv4("127.0.0.1"), 8080; reuseaddr=false)
true

Last updated: Nov 22 2024 at 04:41 UTC