~/talk

HTTP Server on random available port in Go

Talkat Conf42 Golang 2022 · 2022-03-29..03-30· [networking, go]
slides:none on file

Shows that calling net.Listen("tcp", ":0") is the practical way to get a random port and that net/http/test uses the same. Explains internals: net.LookupPort returns 0, net/internal creates a socket, then the kernel runs three system calls bind listen getsockname to pick and report the ephemeral port. Notes to check OS ephemeral port ranges (transcript cites Windows Server 2003 as 1025–535000), and infrastructure limits like Fargate and firewall rules before relying on randomly assigned ports.

AI-written summary · about

  1. 0:00Introduction
  2. 1:13Motivation for random port binding
  3. 2:58HTTP server on random port
  4. 3:40Using port zero
  5. 5:03How net.Listen works
  6. 6:30Network and port resolution
  7. 8:14System calls and sockets
  8. 10:23Bind call assigns port
  9. 11:27OS port range specs
  10. 12:11Infrastructure compatibility
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.