Skip to content

Interface: IInterfaceListener ​

说明

本页由源码中的注释生成,内容为英文。

The listener of a network interface for a server: it accepts the connections of the interface and gives them to the server, whatever the addresses of the interface, again when they change and when the interface is unplugged and plugged back. The server itself does not listen. The InterfaceListener of @lakutata/netif implements it.

Properties ​

addresses ​

readonly addresses: IListeningAddress[]

The addresses it can be reached at now: none while the interface does not exist or has no address.


closed ​

readonly closed: boolean

Whether it was closed.


enforced ​

readonly enforced: boolean

Whether the system refuses the connections that reach the addresses of the interface through another interface.


listening ​

readonly listening: boolean

Whether the interface is listened on now.


networkInterface ​

readonly networkInterface: object

The interface listened on: its name (undefined while it does not exist), and whether it is the loopback one.

loopback ​

readonly loopback: boolean

name ​

readonly name: string | undefined


port ​

readonly port: number | undefined

The port, undefined until a port 0 is given one by the system.


reason ​

readonly reason: string | undefined

Why enforced is false, when it is.

Methods ​

close() ​

close(): Promise<void>

Stop listening; the connections established are left to the server.

Returns ​

Promise<void>


off() ​

off(event, listener): this

Remove a listener of an event.

Parameters ​

event ​

"listening" | "error" | "enforced" | "close"

The event.

listener ​

(...args) => void

The listener given to on().

Returns ​

this


on() ​

Call Signature ​

on(event, listener): this

The interface is listened on, again after a change.

Parameters ​
event ​

"listening"

'listening'.

listener ​

() => void

Called without argument.

Returns ​

this

Call Signature ​

on(event, listener): this

A failure of listening again, retried by the listener; with strict, the guarantee lost.

Parameters ​
event ​

"error"

'error'.

listener ​

(error) => void

Called with the error.

Returns ​

this

Call Signature ​

on(event, listener): this

enforced changed.

Parameters ​
event ​

"enforced"

'enforced'.

listener ​

(enforced) => void

Called with its new value.

Returns ​

this

Call Signature ​

on(event, listener): this

The listener was closed.

Parameters ​
event ​

"close"

'close'.

listener ​

() => void

Called without argument.

Returns ​

this

Released under the MIT License.