Liking cljdoc? Tell your friends :D

get-port

Get an available TCP port for Clojure.

The latest versions on Clojar

Clojars Project

Installation

For deps.edn:

prestancedesign/get-port {:mvn/version "0.1.0"}

For project.clj:

[prestancedesign/get-port "0.1.0"]

Usage

(ns hello-world.core
  (:require [prestancedesign.get-port :refer [get-port]]
            [ring.adapter.jetty :as server]))

...

(server/run-jetty handler {:port (get-port)}) ; Get a random port

Pass in a preferred port:

(get-port {:port 3000})

Pass in an array of preferred ports:

(get-port {:port [3000 3004 3010]})

Use the make-range helper in case you need a port in a certain range:

(get-port {:port (make-range 3000 3005)})

Copyright © 2020 Michaël SALIHI

Distributed under the Eclipse Public License, the same as Clojure.

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close