homepage: https://github.com/jfischoff/port-utilities#readme
changelog-type: markdown
hash: 5d05c28348d95891a85d83a6a50efdccaafbd47decf1fbb2d96ed9de203c5d65
test-bench-deps:
  stm: -any
  base: ! '>=4.7 && <5'
  hspec: -any
  port-utils: -any
  network: -any
  async: -any
maintainer: jonathangfischoff@gmail.com
synopsis: Utilities for creating and waiting on ports
changelog: ! '# Changelog for wait-on-port

  - 0.0.0.1 First version

'
basic-deps:
  base: ! '>=4.7 && <5'
  network: -any
all-versions:
- '0.1.0.0'
author: Jonathan Fischoff
latest: '0.1.0.0'
description-type: markdown
description: ! '# port-utilities


  ## openFreePort


  This 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.


  ```haskell

  openFreePort :: IO (Int, Socket)

  ```


  ## wait


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


  Here is an example of the primary function:


  ```haskell

  import Network.Socket.Wait (wait)


  void $ forkIO $ Warp.run 7000 app

  -- Wait for the server to start listening on the socket

  wait "127.0.0.1" 7000

  -- Communicate with the server

  ...

  ```


  In bash one could write:


  ```bash

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

  ```


  The above was copied from this stackoverflow answer https://stackoverflow.com/a/50008755'
license-name: BSD3

Update from Hackage at 2018-11-02T07:33:36Z
Update from Hackage at 2018-11-02T07:33:36Z
