Io module

sys_prepare_listener

procedureextensionexperimental2 overloadssince 0.31.0Source

The options a listening socket gets before bind: the address may be reused after a restart, and with reuse_port several listeners (one per thread) may share it.

sys_prepare_listener :: (fd: s64, reuse_port: bool) -> s64

Parameters

fd: s64
reuse_port: bool

Returns

s64
sys_prepare_listener :: (fd: s64, reuse_port: bool) -> s64

Windows has no SO_REUSEPORT, and its SO_REUSEADDR lets other programs take the port over. A plain listener therefore asks for the opposite (exclusive use); one that wants to share the port between threads uses SO_REUSEADDR, which on Windows does not balance connections: the system hands them to one of the listeners.

Parameters

fd: s64
reuse_port: bool

Returns

s64

See also