packages feed

port-utils-0.1.0.2 / README.md

# port-utils## openFreePortThis is another version of `warp`'s `openFreePort` function. Nice if you don't already depend on `warp`.`openFreePort` returns a socket on random port and the port it has been bound to.```haskellopenFreePort :: IO (Int, Socket)```## wait`wait` will attempt to connect to a host and port until successful. Between each unsuccessful attempt it sleeps for 10 msHere is an example of the primary function:```haskellimport Network.Socket.Wait (wait)void $ forkIO $ Warp.run 7000 app-- Wait for the server to start listening on the socketwait "127.0.0.1" 7000-- Communicate with the server...```In bash one could write:```bashwhile ! nc -z localhost 7000 ; do sleep 0.01 ; done```The above was copied from this stackoverflow answer https://stackoverflow.com/a/50008755