Atom

http.listen()

Opens an HTTP listener.

Signature

http.listen(host, port[, options])

Parameters

Host, port and optional TCP settings from net, including certificate and key for HTTPS.

Returns

TCP listener handle.

Behavior

Close with net.close. Run http.serve with a handler to start processing requests.

Errors

UDP setting, invalid TLS options, bind failure or denied network access.

Example

Atom
use http
use net
s = http.listen('127.0.0.1', 0)
assert(net.local(s).port > 0)
net.close(s)