# on-net-listen

> Observe when something in your node app starts listening on a TCP port

Latest version **1.1.2** (published 2018-08-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install on-net-listen
pnpm add on-net-listen
yarn add on-net-listen
bun add on-net-listen
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2018-08-08 |
| First published | 2018-01-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=9.4.0 \|\| ^8.9.4 |
| Dependencies | 0 |
| Unpacked size | 5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 28 |
| Author | Mathias Buus |
| Maintainers | mafintosh |

## Links

- npm: https://www.npmjs.com/package/on-net-listen
- Repository: https://github.com/mafintosh/on-net-listen
- Issues: https://github.com/mafintosh/on-net-listen/issues
- npm.io page: https://npm.io/package/on-net-listen

## Recent versions

- 1.1.2 (latest) — 2018-08-08
- 1.1.1 — 2018-05-04
- 1.1.0 — 2018-03-09
- 1.0.0 — 2018-01-18

## README

# on-net-listen

Observe when something in your node app starts listening on a TCP port.

```
npm install on-net-listen
```

[![build status](https://travis-ci.org/mafintosh/on-net-listen.svg?branch=master)](https://travis-ci.org/mafintosh/on-net-listen)

Uses `async_hooks` behind the scenes and requires Node >=9

## Usage

``` js
var onnetlisten = require('on-net-listen')

onnetlisten(function (addr) {
  // addr is the same object as server.address()
  // for the port do addr.port
  console.log('Someone started listening:', addr)
})

var http = require('http')

var server = http.createServer(function () {
  // ...
})

server.listen(0) // will trigger the above listener
```

## API

#### `var emitter = onnetlisten(onlistening)`

Start listening for when TCP servers start listening.

The returned event emitter emits `listening` when that happens
with the address object for the tcp server that started listening.

To stop the listener do `emitter.destroy()`

## Acknowledgements

Credit to [@andreasmadsen](https://github.com/andreasmadsen) for writing most of this module and being an async_hooks wizard

This project was kindly sponsored by nearForm.

## License

MIT

---
_Source: https://npm.io/package/on-net-listen · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
