{"id":15010965,"url":"https://github.com/jfischoff/port-utils","last_synced_at":"2025-04-09T18:35:32.573Z","repository":{"id":56875109,"uuid":"155795963","full_name":"jfischoff/port-utils","owner":"jfischoff","description":"Utilities for creating and waiting on sockets ","archived":false,"fork":false,"pushed_at":"2019-04-27T20:41:58.000Z","size":49,"stargazers_count":3,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-23T20:37:18.514Z","etag":null,"topics":["haskell","networking","testing"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jfischoff.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-02T01:11:25.000Z","updated_at":"2022-02-02T12:35:42.000Z","dependencies_parsed_at":"2022-08-20T22:00:40.702Z","dependency_job_id":null,"html_url":"https://github.com/jfischoff/port-utils","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfischoff%2Fport-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfischoff%2Fport-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfischoff%2Fport-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfischoff%2Fport-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jfischoff","download_url":"https://codeload.github.com/jfischoff/port-utils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248088478,"owners_count":21045718,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["haskell","networking","testing"],"created_at":"2024-09-24T19:37:55.806Z","updated_at":"2025-04-09T18:35:32.547Z","avatar_url":"https://github.com/jfischoff.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# port-utils\n\n## openFreePort\n\nThis is another version of `warp`'s `openFreePort` function. This function has fewer dependencies than the `warp` version.\n\n`openFreePort` returns a socket on a random port and the port it has been bound to.\n\n```haskell\nopenFreePort :: IO (Int, Socket)\n```\n\n## wait\n\n`wait` will attempt to connect to a host and port until it is successful. Between each unsuccessful attempt, it sleeps for 10 ms.\n\nHere is an example of the primary function:\n\n```haskell\nimport Network.Socket.Wait (wait)\n\nvoid $ forkIO $ Warp.run 7000 app\n-- Wait for the server to start listening on the socket\nwait \"127.0.0.1\" 7000\n-- Communicate with the server\n...\n```\n\nIn bash one could write:\n\n```bash\nwhile ! nc -z localhost 7000 ; do sleep 0.01 ; done\n```\n\nThe bash script above was copied from this stackoverflow answer https://stackoverflow.com/a/50008755","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjfischoff%2Fport-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjfischoff%2Fport-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjfischoff%2Fport-utils/lists"}