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
readonlyaddresses:IListeningAddress[]
The addresses it can be reached at now: none while the interface does not exist or has no address.
closed
readonlyclosed:boolean
Whether it was closed.
enforced
readonlyenforced:boolean
Whether the system refuses the connections that reach the addresses of the interface through another interface.
listening
readonlylistening:boolean
Whether the interface is listened on now.
networkInterface
readonlynetworkInterface:object
The interface listened on: its name (undefined while it does not exist), and whether it is the loopback one.
loopback
readonlyloopback:boolean
name
readonlyname:string|undefined
port
readonlyport:number|undefined
The port, undefined until a port 0 is given one by the system.
reason
readonlyreason: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