Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/phayes/freeport
Get a free and open tcp port that is ready to use
https://github.com/phayes/freeport
Last synced: 4 days ago
JSON representation
Get a free and open tcp port that is ready to use
- Host: GitHub
- URL: https://github.com/phayes/freeport
- Owner: phayes
- License: other
- Created: 2014-11-06T21:10:41.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-01-16T06:53:35.000Z (10 months ago)
- Last Synced: 2024-08-01T13:31:46.786Z (3 months ago)
- Language: Go
- Homepage:
- Size: 16.6 KB
- Stars: 363
- Watchers: 5
- Forks: 40
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-ccamel - phayes/freeport - Get a free and open tcp port that is ready to use (Go)
README
FreePort
========Get a free open TCP port that is ready to use.
## Command Line Example:
```bash
# Ask the kernel to give us an open port.
export port=$(freeport)# Start standalone httpd server for testing
httpd -X -c "Listen $port" &# Curl local server on the selected port
curl localhost:$port
```## Golang example:
```go
package mainimport "github.com/phayes/freeport"
func main() {
port, err := freeport.GetFreePort()
if err != nil {
log.Fatal(err)
}
// port is ready to listen on
}```
## Installation
#### Mac OSX
```bash
brew install phayes/repo/freeport
```#### CentOS and other RPM based systems
```bash
wget https://github.com/phayes/freeport/releases/download/1.0.2/freeport_1.0.2_linux_386.rpm
rpm -Uvh freeport_1.0.2_linux_386.rpm
```#### Ubuntu and other DEB based systems
```bash
wget wget https://github.com/phayes/freeport/releases/download/1.0.2/freeport_1.0.2_linux_amd64.deb
dpkg -i freeport_1.0.2_linux_amd64.deb
```#### Building From Source
```bash
sudo apt-get install golang # Download go. Alternativly build from source: https://golang.org/doc/install/source
go get github.com/phayes/freeport
```