std.lib.network

local-host

added in 3.0

(local-host)

returns the current host

(local-host) ;; #objectjava.net.Inet4Address 0x4523dee “chapterhouse.base.local/127.0.0.1” => java.net.Inet4Address

local-hostname

added in 3.0

(local-hostname)

returns the current host name

(local-hostname) ;; “chapterhouse.base.local” => string?

local-ip

added in 3.0

(local-ip)

returns the current ip

(local-ip) ;; “127.0.0.1” => string?

local-ip-lan

added in 4.0

(local-ip-lan)

returns a non-loopback lan ipv4 address, preferring 192.168., then 10., then 172.16-31.*

(local-ip-lan) ;; => “192.168.1.42” => string?

local-shortname

added in 3.0

(local-shortname)

returns the current host short name

(local-shortname) ;; “chapterhouse” => string?

port:check-available

added in 4.0

(port:check-available port)

check that port is available

(port:check-available 51311) => anything

port:get-available

added in 4.0

(port:get-available ports)

get first available port from a range

(port:get-available 51312 51313) => number?

socket

added in 3.0

(socket port)(socket host port)

creates a new socket

(h/suppress (with-open s ^java.net.Socket (socket 51311) s))

socket:address

added in 3.0

(socket:address socket)

gets the remote socket address

socket:local-address

added in 3.0

(socket:local-address socket)

getst the local socket address

socket:local-port

added in 3.0

(socket:local-port socket)

gets the local socket port

socket:port

added in 3.0

(socket:port socket)

gets the remote socket port

wait-for-port

added in 3.0

(wait-for-port host port)(wait-for-port host port {:keys [timeout pause], :as opts})

waits for a port to be ready

(wait-for-port “localhost” 51313 {:timeout 1000}) => (throws)