Returns a future for a SecureServerSocket. When the future
completes the server socket is bound to the given address
and
port
and has started listening on it.
The address
can either be a String or an
InternetAddress. If address
is a String, bind will
perform a InternetAddress.lookup and use the first value in the
list. To listen on the loopback adapter, which will allow only
incoming connections from the local host, use the value
InternetAddress.LOOPBACK_IP_V4 or
InternetAddress.LOOPBACK_IP_V6. To allow for incoming
connection from the network use either one of the values
InternetAddress.ANY_IP_V4 or InternetAddress.ANY_IP_V6 to
bind to all interfaces or the IP address of a specific interface.
If port
has the value 0
an ephemeral port will be chosen by
the system. The actual port used can be retrieved using the
port
getter.
The optional argument backlog
can be used to specify the listen
backlog for the underlying OS listen setup. If backlog
has the
value of 0
(the default) a reasonable value will be chosen by
the system.
Incoming client connections are promoted to secure connections, using
the server certificate given by certificateName
.
address
must be given as a numeric address, not a host name.
To request or require that clients authenticate by providing an SSL (TLS)
client certificate, set the optional parameter requestClientCertificate
or requireClientCertificate
to true. Requiring a certificate implies
requesting a certificate, so one doesn't need to set both to true.
To check whether a client certificate was received, check
SecureSocket.peerCertificate after connecting. If no certificate
was received, the result will be null.
The optional argument shared
specify whether additional binds
to the same address
, port
and v6Only
combination is
possible from the same Dart process. If shared
is true
and
additional binds are performed, then the incoming connections
will be distributed between that set of
SecureServerSocket
s. One way of using this is to have number of
isolates between which incoming connections are distributed.
Source
static Future<SecureServerSocket> bind(
address,
int port,
SecurityContext context,
{int backlog: 0,
bool v6Only: false,
bool requestClientCertificate: false,
bool requireClientCertificate: false,
List<String> supportedProtocols,
bool shared: false}) {
return RawSecureServerSocket.bind(
address,
port,
context,
backlog: backlog,
v6Only: v6Only,
requestClientCertificate: requestClientCertificate,
requireClientCertificate: requireClientCertificate,
supportedProtocols: supportedProtocols,
shared: shared).then(
(serverSocket) => new SecureServerSocket._(serverSocket));
}