serveNative method

Future<RelicServer> serveNative({
  1. InternetAddress? address,
  2. int port = 8080,
  3. int noOfIsolates = 1,
  4. NativeOptions options = const NativeOptions(),
  5. NativeTls? tls,
})

Starts a native server on address and port that sends requests to this app.

noOfIsolates isolates handle requests and share one native server, bound once. Each call mints its own group, so two calls never share a server and port 0 works with several isolates.

address defaults to InternetAddress.loopbackIPv4. options and tls go to NativeAdapter.bind, and with tls the server speaks HTTPS.

Implementation

Future<RelicServer> serveNative({
  InternetAddress? address,
  int port = 8080,
  int noOfIsolates = 1,
  NativeOptions options = const NativeOptions(),
  NativeTls? tls,
}) {
  final group = 'relic_native/$pid/${_serveCount++}';
  return run(
    () => NativeAdapter.bind(
      address ?? InternetAddress.loopbackIPv4,
      port: port,
      group: group,
      options: options,
      tls: tls,
    ),
    noOfIsolates: noOfIsolates,
  );
}