NIOCore
import NIOCore
import NIOCore
typealias ChannelDuplexHandler
A combination of ChannelInboundHandler
and ChannelOutboundHandler
.
typealias NIOPOSIXFileMode
typealias NIOSendable
typealias SocketOptionLevel
typealias SocketOptionName
typealias SocketOptionValue
enum ByteToMessageDecoderError
Common errors thrown by ByteToMessageDecoder
s.
enum ChannelError
An error that can occur on Channel
operations.
enum ChannelEvent
An Channel
related event that is passed through the ChannelPipeline
to notify the user.
enum ChannelPipelineError
Error
that is used by the ChannelPipeline
to inform the user of an error.
enum CloseMode
Specify what kind of close operation is requested.
enum DatagramChannelError
enum DecodingState
State of the current decoding process.
enum Endianness
Endianness refers to the sequential order in which bytes are arranged into larger numerical values when stored in memory or when transmitted over digital links.
enum EventLoopError
Different Error
s that are specific to EventLoop
operations / implementations.
enum IOData
IOData
unifies standard SwiftNIO types that are raw bytes of data; currently ByteBuffer
and FileRegion
.
enum NIOBSDSocket
enum NIOEventLoopGroupProvider
This type is intended to be used by libraries which use NIO, and offer their users either the option to .share
an existing event loop group or create (and manage) a new one (.createNew
) and let it be managed by given library and its lifecycle.
enum NIOExplicitCongestionNotificationState
Possible Explicit Congestion Notification States
enum SocketAddress
Represent a socket address to which we may want to connect or bind.
enum SocketAddressError
Special Error
that may be thrown if we fail to create a SocketAddress
.
enum System
struct AdaptiveRecvByteBufferAllocator
RecvByteBufferAllocator
which will gracefully increment or decrement the buffer size on the feedback that was recorded.
struct AddressedEnvelope
A data structure for processing addressed datagrams, such as those used by UDP.
struct ByteBuffer
ByteBuffer
stores contiguously allocated raw bytes. It is a random and sequential accessible sequence of zero or more bytes (octets).
struct ByteBufferAllocator
The preferred allocator for ByteBuffer
values. The allocation strategy is opaque but is currently libc’s malloc
, realloc
and free
.
struct ByteBufferView
A view into a portion of a ByteBuffer
.
struct ChannelOptions
Provides ChannelOption
s to be used with a Channel
, Bootstrap
or ServerBootstrap
.
struct ChannelShouldQuiesceEvent
A Channel
user event that is sent when the Channel
has been asked to quiesce.
struct CircularBuffer
An automatically expanding ring buffer implementation backed by a ContiguousArray
. Even though this implementation will automatically expand if more elements than initialCapacity
are stored, it’s advantageous to prevent expansions from happening frequently. Expansions will always force an allocation and a copy to happen.
struct EventLoopIterator
An iterator over the EventLoop
s forming an EventLoopGroup
.
struct EventLoopPromise
A promise to provide a result later.
struct FileRegion
A FileRegion
represent a readable portion usually created to be sent over the network.
struct FixedSizeRecvByteBufferAllocator
RecvByteBufferAllocator
which will always return a ByteBuffer
with the same fixed size no matter what was recorded.
struct IOError
An Error
for an IO operation.
struct MarkedCircularBuffer
A circular buffer that allows one object at a time to be “marked” and easily identified and retrieved later.
struct NIOAny
NIOAny
is an opaque container for values of any type, similar to Swift’s builtin Any
type. Contrary to Any
the overhead of NIOAny
depends on the the type of the wrapped value. Certain types that are important for the performance of a SwiftNIO application like ByteBuffer
, FileRegion
and AddressEnvelope<ByteBuffer>
can be expected to be wrapped almost without overhead. All others will have similar performance as if they were passed as an Any
as NIOAny
just like Any
will contain them within an existential container.
struct NIOAttemptedToRemoveHandlerMultipleTimesError
The removal of a ChannelHandler
using ChannelPipeline.removeHandler
has been attempted more than once.
struct NIOClientTCPBootstrap
NIOClientTCPBootstrap
is a bootstrap that allows you to bootstrap client TCP connections using NIO on BSD Sockets, NIO Transport Services, or other ways.
struct NIODeadline
Represents a point in time.
struct NIOInsecureNoTLS
struct NIOMulticastNotImplementedError
Multicast has not been properly implemented on this channel.
struct NIOMulticastNotSupportedError
Multicast is not supported on this interface.
struct NIONetworkDevice
A representation of a single network device on a system.
struct NIOPacketInfo
struct NIOTooManyBytesError
struct Scheduled
Returned once a task was scheduled on the EventLoop
for later execution.
struct TimeAmount
Represents a time interval.
class AcceptBackoffHandler
A ChannelHandler
that implements a backoff for a ServerChannel
when accept produces an IOError
. These errors are often recoverable by reducing the rate at which we call accept.
class BackPressureHandler
ChannelHandler implementation which enforces back-pressure by stopping to read from the remote peer when it cannot write back fast enough. It will start reading again once pending data was written.
class ByteToMessageHandler
A handler which turns a given ByteToMessageDecoder
into a ChannelInboundHandler
that can then be added to a ChannelPipeline
.
class ChannelHandlerContext
Every ChannelHandler
has – when added to a ChannelPipeline
– a corresponding ChannelHandlerContext
which is the way ChannelHandler
s can interact with other ChannelHandler
s in the pipeline.
class ChannelPipeline
A list of ChannelHandler
s that handle or intercept inbound events and outbound operations of a Channel
. ChannelPipeline
implements an advanced form of the Intercepting Filter pattern to give a user full control over how an event is handled and how the ChannelHandler
s in a pipeline interact with each other.
class EventLoopFuture
Holder for a result that will be provided later.
class IdleStateHandler
Triggers an IdleStateEvent when a Channel has not performed read, write, or both operation for a while.
class MessageToByteHandler
A handler which turns a given MessageToByteEncoder
into a ChannelOutboundHandler
that can then be added to a ChannelPipeline
.
class NIOCloseOnErrorHandler
A ChannelInboundHandler
that closes the channel when an error is caught
class NIOFileHandle
A NIOFileHandle
is a handle to an open file.
class NIOSingleStepByteToMessageProcessor
NIOSingleStepByteToMessageProcessor
uses a NIOSingleStepByteToMessageDecoder
to produce messages from a stream of incoming bytes. It works like ByteToMessageHandler
but may be used outside of the channel pipeline. This allows processing of wrapped protocols in a general way.
class RepeatedTask
Returned once a task was scheduled to be repeatedly executed on the EventLoop
.
protocol ByteToMessageDecoder
ByteToMessageDecoder
s decode bytes in a stream-like fashion from ByteBuffer
to another message type.
protocol Channel
A Channel
is easiest thought of as a network socket. But it can be anything that is capable of I/O operations such as read, write, connect, and bind.
protocol ChannelCore
The core Channel
methods that are for internal use of the Channel
implementation only.
protocol ChannelHandler
You should never implement this protocol directly. Please implement one of its sub-protocols.
protocol ChannelInboundHandler
ChannelHandler
which handles inbound I/O events for a Channel
.
protocol ChannelInboundInvoker
Fire inbound events related to a Channel
through the ChannelPipeline
until its end is reached or it’s consumed by a ChannelHandler
.
protocol ChannelInvoker
A protocol that signals that outbound and inbound events are triggered by this invoker.
protocol ChannelOption
A configuration option that can be set on a Channel
to configure different behaviour.
protocol ChannelOutboundHandler
ChannelHandler
which handles outbound I/O events or intercept an outbound I/O operation for a Channel
.
protocol ChannelOutboundInvoker
Allows users to invoke an “outbound” operation related to a Channel
that will flow through the ChannelPipeline
until it will finally be executed by the the ChannelCore
implementation.
protocol EventLoop
An EventLoop processes IO / tasks in an endless loop for Channel
s until it’s closed.
protocol EventLoopGroup
Provides an endless stream of EventLoop
s to use.
protocol FileDescriptor
protocol MessageToByteEncoder
A protocol for straightforward encoders which encode custom messages to ByteBuffer
s. To add a MessageToByteEncoder
to a ChannelPipeline
, use channel.pipeline.addHandler(MessageToByteHandler(myEncoder)
.
protocol MulticastChannel
A MulticastChannel
is a Channel
that supports IP multicast operations: that is, a channel that can join multicast groups.
protocol NIOClientTCPBootstrapProtocol
NIOClientTCPBootstrapProtocol
is implemented by various underlying transport mechanisms. Typically, this will be the BSD Sockets API implemented by ClientBootstrap
.
protocol NIOClientTLSProvider
protocol NIOPreconcurrencySendable
protocol NIOSingleStepByteToMessageDecoder
A simplified version of ByteToMessageDecoder
that can generate zero or one messages for each invocation of decode
or decodeLast
. Having decode
and decodeLast
return an optional message avoids re-entrancy problems, since the functions relinquish exclusive access to the ByteBuffer
when returning. This allows for greatly simplified processing.
protocol NIOSynchronousChannelOptions
protocol RecvByteBufferAllocator
Allocates ByteBuffer
s to be used to read bytes from a Channel
and records the number of the actual bytes that were used.
protocol RemovableChannelHandler
A RemovableChannelHandler
is a ChannelHandler
that can be dynamically removed from a ChannelPipeline
whilst the Channel
is operating normally. A RemovableChannelHandler
is required to remove itself from the ChannelPipeline
(using ChannelHandlerContext.removeHandler
) as soon as possible.
protocol SocketOptionProvider
This protocol defines an object, most commonly a Channel
, that supports setting and getting socket options (via setsockopt
/getsockopt
or similar). It provides a strongly typed API that makes working with larger, less-common socket options easier than the ChannelOption
API allows.
protocol WriteObservingByteToMessageDecoder
Some ByteToMessageDecoder
s need to observe write
s (which are outbound events). ByteToMessageDecoder
s which implement the WriteObservingByteToMessageDecoder
protocol will be notified about every outbound write.
typealias AllocatorOption
typealias AllowRemoteHalfClosureOption
typealias AutoReadOption
typealias BacklogOption
typealias ConnectTimeoutOption
typealias DatagramVectorReadMessageCountOption
typealias MaxMessagesPerReadOption
typealias RecvAllocatorOption
typealias SocketOption
typealias WriteBufferWaterMark
typealias WriteBufferWaterMarkOption
typealias WriteSpinOption
class NIONetworkInterface
A representation of a single network interface on a system.