dream/servers/mist/port_probe

Internal port availability probe for Mist servers.

Uses a short TCP connect attempt to determine if a port is already in use.

Values

pub fn is_in_use(
  interface: option.Option(String),
  port: Int,
) -> Bool

Check whether a port is already in use on the given interface.

This performs a short TCP connect attempt and returns True when a listener is already bound, False otherwise. It defaults to "localhost" when no interface is provided.

Parameters

  • interface: The interface to check. Use Some("127.0.0.1"), Some("0.0.0.0"), or Some("localhost"). Pass None to use "localhost".
  • port: The TCP port number to probe.

This function is intended for internal server startup checks.

Example

import gleam/option.{None}
import dream/servers/mist/port_probe

let in_use = port_probe.is_in_use(None, 3000)
Search Document