BSD-3-Clause licensed by Jonathan Fischoff
Maintained by [email protected]

Module documentation for

This version can be pinned in stack with:[email protected]:0e7cdb91e40cadedc528260bd5919414876c6f9eb250f9f54ace9fe7a12384ab,1944



This is another version of warp’s openFreePort function. This function has fewer dependencies than the warp version.

openFreePort returns a socket on a random port and the port it has been bound to.

openFreePort :: IO (Int, Socket)


wait will attempt to connect to a host and port until it is successful. Between each unsuccessful attempt, it sleeps for 10 ms.

Here is an example of the primary function:

import Network.Socket.Wait (wait)

void $ forkIO $ 7000 app
-- Wait for the server to start listening on the socket
wait "" 7000
-- Communicate with the server

In bash one could write:

while ! nc -z localhost 7000 ; do sleep 0.01 ; done

The bash script above was copied from this stackoverflow answer


Changelog for wait-on-port

  • First version

  • Rework internals and change EventHandlers to EventHandlers m. Fix bug if host could not be found. It would loop forever and now throws.

Depends on 2 packages(full list with versions):
Used by 1 package in lts-15.3(full list with versions):