{"id":27883918,"url":"https://github.com/medz/freeport","last_synced_at":"2025-05-05T06:20:48.896Z","repository":{"id":278330204,"uuid":"935272391","full_name":"medz/freeport","owner":"medz","description":"A fast and reliable Dart library for finding available network ports.","archived":false,"fork":false,"pushed_at":"2025-04-16T03:51:49.000Z","size":20,"stargazers_count":1,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-03T23:49:49.824Z","etag":null,"topics":["network","port","socket","utility"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/freeport","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/medz.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-19T07:18:14.000Z","updated_at":"2025-03-15T12:22:59.000Z","dependencies_parsed_at":"2025-02-19T07:35:51.052Z","dependency_job_id":"0296e182-6ffe-4b1c-9056-d3e03556dc5d","html_url":"https://github.com/medz/freeport","commit_stats":null,"previous_names":["medz/freeport"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/medz%2Ffreeport","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/medz%2Ffreeport/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/medz%2Ffreeport/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/medz%2Ffreeport/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/medz","download_url":"https://codeload.github.com/medz/freeport/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252448788,"owners_count":21749548,"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":["network","port","socket","utility"],"created_at":"2025-05-05T06:20:48.329Z","updated_at":"2025-05-05T06:20:48.886Z","avatar_url":"https://github.com/medz.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# freeport\n\nA fast and reliable Dart library for finding available network ports. Supports parallel port checking, preferred ports selection, custom hostnames and detailed port availability verification.\n\n[![pub package](https://img.shields.io/pub/v/freeport.svg)](https://pub.dev/packages/freeport)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n[![Tests](https://github.com/medz/freeport/actions/workflows/test.yml/badge.svg)](https://github.com/medz/freeport/actions/workflows/test.yml)\n\n## What is freeport?\n\nFreeport is a zero-dependency, lightweight Dart utility designed to solve the common problem of finding available network ports for your applications. Whether you're developing web servers, microservices, or any networked application, freeport provides a reliable way to:\n\n- Obtain available ports dynamically at runtime\n- Check if specific ports are available before use\n- Try preferred ports first before falling back to random ones\n- Optimize port checking with parallel processing\n\n## Features\n\n- **Fast parallel port checking** - Check multiple ports simultaneously for better performance\n- **Preferred port selection** - Specify ports to try first in order of preference\n- **Smart fallback strategy** - Two-stage checking ensures reliability when ports are busy\n- **Custom hostname support** - Bind to specific network interfaces or IP addresses\n- **Environment variable configuration** - Use environment variables for default settings\n\n## Installation\n\nTo install `freeport`, run the command:\n\n```bash\ndart pub add freeport\n```\n\n## Usage\n\n### Finding a free port\n\n```dart\n// Get any free port\nfinal port = await freePort();\n\n// Try preferred ports first (with optimized parallel checking)\nfinal port = await freePort(preferred: [8080, 8081, 8082, 8083]);\n\n// Specify hostname\nfinal port = await freePort(hostname: '127.0.0.1');\n```\n\n### Checking port availability\n\n```dart\nif (await isAvailablePort(8080)) {\n  print('Port 8080 is available');\n}\n\n// Check on a specific host\nif (await isAvailablePort(8080, hostname: '192.168.1.1')) {\n  print('Port 8080 is available on 192.168.1.1');\n}\n```\n\n### Custom hostname\n\nThe hostname parameter can be:\n\n- An `InternetAddress` object\n- A String IP address\n- `null` (uses HOST env var or loopback)\n\n```dart\n// Using string IP\nfinal port = await freePort(hostname: '192.168.1.1');\n\n// Using InternetAddress\nfinal address = InternetAddress('127.0.0.1');\nfinal port = await freePort(hostname: address);\n```\n\n## Performance Optimization\n\nThe `freePort` function uses a two-stage port checking strategy:\n\n1. First attempts parallel checking of all preferred ports for maximum speed\n2. Falls back to sequential checking if needed for reliability\n\nThis approach significantly improves performance when checking multiple preferred ports.\n\n## Environment Variables\n\n- `HOST` - Default hostname to use when none specified\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmedz%2Ffreeport","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmedz%2Ffreeport","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmedz%2Ffreeport/lists"}