serve method
- Object address,
- int port, {
- SecurityContextFactory? securityContextFactory,
- int backlog = 0,
- bool v6Only = false,
- bool requestClientCertificate = false,
- int isolates = 1,
- LoggerFactory? loggerFactory = defaultLoggerFactory,
- bool showBanner = true,
- bool showUrl = true,
Starts a Server that listens on the specified address
and
port
and sends requests to mounted Application.
The address
can either be a String or an InternetAddress. If
address
is a String, ApplicationServer.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.loopbackIPv4 or
InternetAddress.loopbackIPv6. To allow for incoming connection from the
network use either one of the values InternetAddress.anyIPv4 or
InternetAddress.anyIPv6 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.
Incoming client connections are promoted to secure connections, using the
certificate and key set in SecurityContext created by
securityContextFactory
.
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.
If requestClientCertificate
is true
, the server will request clients
to authenticate with a client certificate. The server will advertise the
names of trusted issuers of client certificates, getting them from a
SecurityContext, where they have been set using
SecurityContext.setClientAuthorities.
The optional argument shared
specifies whether additional
ApplicationServer objects can bind to the same combination of address
,
port
and v6Only
. If shared
is true
and more Servers from this
isolate or other isolates are bound to the port, then the incoming
connections will be distributed among all the bound Servers. Connections
can be distributed over multiple isolates this way.
The optional argument loggerFactory
specifies a logger factory that
creates a Logger
for this Server instance.
Implementation
Future<Server> serve(
Object address,
int port, {
SecurityContextFactory? securityContextFactory,
int backlog = 0,
bool v6Only = false,
bool requestClientCertificate = false,
bool shared = false,
int isolates = 1,
LoggerFactory? loggerFactory = defaultLoggerFactory,
bool showBanner = true,
bool showUrl = true,
}) async {
var applicationOrFuture = this;
Future<Application> applicationFactory() async {
return await applicationOrFuture;
}
return applicationFactory.serve(address, port,
securityContextFactory: securityContextFactory,
backlog: backlog,
v6Only: v6Only,
requestClientCertificate: requestClientCertificate,
shared: shared,
isolates: isolates,
loggerFactory: loggerFactory,
showBanner: showBanner,
showUrl: showUrl);
}