An open API service indexing awesome lists of open source software.

https://github.com/thecount/go-multilisten

Bundle multiple Golang net.Listeners into a single one.
https://github.com/thecount/go-multilisten

golang-package listen network

Last synced: 5 months ago
JSON representation

Bundle multiple Golang net.Listeners into a single one.

Awesome Lists containing this project

README

          

# multilisten

![](https://github.com/TheCount/go-multilisten/workflows/CI/badge.svg)
[![Documentation](https://godoc.org/github.com/TheCount/go-multilisten/multilisten?status.svg)](https://godoc.org/github.com/TheCount/go-multilisten/multilisten)

multilisten is a Go package for bundling multiple net.Listeners into a single one.

This package is useful when a third-party package expects a single `net.Listener` to build some service, but you would actually like to listen on several endpoints (ports, specific interfaces, files).

## Install

```sh
go get github.com/TheCount/go-multilisten/multilisten
```

## Usage

For the detailed API, see the [Documentation](https://godoc.org/github.com/TheCount/go-multilisten/multilisten).

Essentially, all you have to do is bundle your listeners like this:

```golang
bundle, err := multilisten.Bundle(l1, l2, l3)
```

and then use `bundle` like a single listener. It will accept from `l1`, `l2` and `l3` simultaneously.