func bootstrap()

in FishyTransport/Sources/FishyActorTransport/FishyTransport+Server.swift [158:179]


  func bootstrap(host: String, port: Int) throws {
    assert(channel == nil)

    let bootstrap = ServerBootstrap(group: group)
        // Specify backlog and enable SO_REUSEADDR for the server itself
        .serverChannelOption(ChannelOptions.backlog, value: 256)
        .serverChannelOption(ChannelOptions.socketOption(.so_reuseaddr), value: 1)

        // Set the handlers that are applied to the accepted Channels
        .childChannelInitializer { channel in
          let httpHandler = HTTPHandler(transport: self.transport)
          return channel.pipeline.configureHTTPServerPipeline().flatMap {
            channel.pipeline.addHandler(httpHandler)
          }
        }

        // Enable SO_REUSEADDR for the accepted Channels
        .childChannelOption(ChannelOptions.socketOption(.so_reuseaddr), value: 1)

    channel = try bootstrap.bind(host: host, port: port).wait()
    assert(channel.localAddress != nil, "localAddress was nil!")
  }