class Server
package js.node.tls
extends Server › EventEmitter
extended by Server
@:jsRequire("tls","Server")This class is a subclass of net.Server
and has the same methods on it.
Instead of accepting just raw TCP connections, this accepts encrypted connections using TLS or SSL.
Methods
addContext(hostname:String, credentials:SecureContextOptions):Void
Add secure context that will be used if client request's SNI hostname is matching passed hostname (wildcards can be used).
getTicketKeys():Buffer
Returns Buffer
instance holding the keys currently used for encryption/decryption of the TLS Session Tickets.
setTicketKeys(keys:Buffer):Void
Updates the keys for encryption/decryption of the TLS Session Tickets.
NOTE: the buffer should be 48 bytes long. See server ticketKeys
option for
more information on how it is going to be used.
NOTE: the change is effective only for the future server connections. Existing or currently pending server connections will use previous keys.
Inherited Variables
Defined by Server
read onlyconnections:Null<Int>
The number of concurrent connections on the server.
This becomes null when sending a socket to a child with child_process.fork().
To poll forks and get current number of active connections use asynchronous getConnections
instead.
maxConnections:Int
Set this property to reject connections when the server's connection count gets high. It is not recommended to use this option once a socket has been sent to a child with child_process.fork().
Inherited Methods
Defined by Server
address():SocketAdress
Returns the bound address, the address family name and port of the server as reported by the operating system. Useful to find which port was assigned when giving getting an OS-assigned address.
close(?callback:() ‑> Void):Void
close(callback:Error ‑> Void):Void
Stops the server from accepting new connections and keeps existing connections. This function is asynchronous, the server is finally closed when all connections are ended and the server emits a 'close' event.
The optional callback will be called once the 'close' event occurs. Unlike that event, it will be called with an Error as its only argument if the server was not open when it was closed.
getConnections(callback:(Error, Int) ‑> Void):Void
Asynchronously get the number of concurrent connections on the server. Works when sockets were sent to forks.
listen(options:EitherType<ServerListenOptionsTcp, ServerListenOptionsUnix>, ?callback:() ‑> Void):Void
listen(path:String, ?callback:() ‑> Void):Void
listen(handle:EitherType<Dynamic, {fd:Int}>, ?callback:() ‑> Void):Void
listen(port:Int, ?callback:() ‑> Void):Void
listen(port:Int, backlog:Int, ?callback:() ‑> Void):Void
listen(port:Int, hostname:String, ?callback:() ‑> Void):Void
listen(port:Int, hostname:String, backlog:Int, ?callback:() ‑> Void):Void
Begin accepting connections on the specified port
and hostname
.
If the hostname
is omitted, the server will accept connections on any IPv6 address (::) when IPv6 is available,
or any IPv4 address (0.0.0.0) otherwise.
A port
value of zero will assign a random port.
backlog
is the maximum length of the queue of pending connections. The actual length will be determined
by your OS through sysctl settings such as tcp_max_syn_backlog and somaxconn on linux.
The default value of this parameter is 511 (not 512).
When path
is provided, start a local socket server listening for connections on the given path.
When handle
is provided, it should be either a server or socket (anything with an underlying _handle
member),
or a {fd:
This function is asynchronous. When the server has been bound, 'listening' event will be emitted.
The last parameter callback
will be added as an listener for the 'listening' event.
Defined by EventEmitter
addListener<T>(eventName:Event<T>, listener:T):TSelf
Alias for emitter.on(eventName, listener)
.
See also:
emit<T>(eventName:Event<T>, args:Rest<Dynamic>):Bool
Synchronously calls each of the listeners registered for the event named
eventName
, in the order they were registered, passing the supplied arguments
to each.
See also:
eventNames():Array<EitherType<String, Symbol>>
Returns an array listing the events for which the emitter has registered
listeners. The values in the array will be strings or Symbol
s.
See also:
getMaxListeners():Int
Returns the current max listener value for the EventEmitter
which is either
set by emitter.setMaxListeners(n)
or defaults to
EventEmitter.defaultMaxListeners
.
See also:
listenerCount<T>(eventName:Event<T>):Int
Returns the number of listeners listening to the event named eventName
.
See also:
listeners<T>(eventName:Event<T>):Array<T>
Returns a copy of the array of listeners for the event named eventName
.
See also:
on<T>(eventName:Event<T>, listener:T):TSelf
Adds the listener
function to the end of the listeners array for the
event named eventName
. No checks are made to see if the listener
has
already been added. Multiple calls passing the same combination of eventName
and listener
will result in the listener
being added, and called, multiple
times.
See also:
once<T>(eventName:Event<T>, listener:T):TSelf
Adds a one-time listener
function for the event named eventName
. The
next time eventName
is triggered, this listener is removed and then invoked.
See also:
prependListener<T>(eventName:Event<T>, listener:T):TSelf
Adds the listener
function to the beginning of the listeners array for the
event named eventName
. No checks are made to see if the listener
has
already been added. Multiple calls passing the same combination of eventName
and listener
will result in the listener
being added, and called, multiple
times.
See also:
prependOnceListener<T>(eventName:Event<T>, listener:T):TSelf
Adds a one-time listener
function for the event named eventName
to the
beginning of the listeners array. The next time eventName
is triggered, this
listener is removed, and then invoked.
See also:
rawListeners<T>(eventName:Event<T>):Array<T>
Returns a copy of the array of listeners for the event named eventName
,
including any wrappers (such as those created by .once()
).
See also:
removeAllListeners<T>(?eventName:Event<T>):TSelf
Removes all listeners, or those of the specified eventName
.
See also:
removeListener<T>(eventName:Event<T>, listener:T):TSelf
Removes the specified listener
from the listener array for the event named
eventName
.
See also:
setMaxListeners(n:Int):Void
By default EventEmitter
s will print a warning if more than 10
listeners are
added for a particular event. This is a useful default that helps finding
memory leaks. Obviously, not all events should be limited to just 10 listeners.
The emitter.setMaxListeners()
method allows the limit to be modified for this
specific EventEmitter
instance. The value can be set to Infinity
(or 0
)
to indicate an unlimited number of listeners.
See also: