public final class DatagramBootstrap

A DatagramBootstrap is an easy way to bootstrap a DatagramChannel when creating datagram clients and servers.


    let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
    defer {
        try! group.syncShutdownGracefully()
    let bootstrap = DatagramBootstrap(group: group)
        // Enable SO_REUSEADDR.
        .channelOption(ChannelOptions.socketOption(.so_reuseaddr), value: 1)
        .channelInitializer { channel in
    let channel = try! bootstrap.bind(host: "", port: 53).wait()
    /* the Channel is now ready to send/receive datagrams */

    try channel.closeFuture.wait()  // Wait until the channel un-binds.

The DatagramChannel will operate on AddressedEnvelope<ByteBuffer> as inbound and outbound messages.