Instance Methodswift-nio 2.72.0NIOPosix
connect(to:channelInitializer:)
Specify the address
to connect to for the TCP Channel
that will be established.
- iOS
- 13+
- macOS
- 10.15+
- tvOS
- 13+
- watchOS
- 6+
func connect<Output>(to address: SocketAddress, channelInitializer: @escaping (Channel) -> EventLoopFuture<Output>) async throws -> Output where Output : Sendable
Parameters
- address
The address to connect to.
- channelInitializer
A closure to initialize the channel. The return value of this closure is returned from the
connect
method.
Returns
The result of the channel initializer.
Other members in extension
Type members
init(group: EventLoopGroup
) Create a
ClientBootstrap
on theEventLoopGroup
group
.init?(validatingGroup: EventLoopGroup
) Create a
ClientBootstrap
on theEventLoopGroup
group
, validating thatgroup
is compatible.
Instance members
func bind(to: SocketAddress
) -> ClientBootstrap Bind the
SocketChannel
toaddress
.func channelInitializer(@escaping (Channel) -> EventLoopFuture<Void>
) -> Self func channelOption<Option>(Option, value: Option.Value
) -> Self func connect(host: String, port: Int
) -> EventLoopFuture<Channel> func connect<Output>(host: String, port: Int, channelInitializer: @escaping (Channel) -> EventLoopFuture<Output>
) async throws -> Output Specify the
host
andport
to connect to for the TCPChannel
that will be established.func connect(to: VsockAddress
) -> EventLoopFuture<Channel> Specify the VSOCK address to connect to for the
Channel
.func connect(to: SocketAddress
) -> EventLoopFuture<Channel> func connect<Output>(to: VsockAddress, channelInitializer: @escaping (Channel) -> EventLoopFuture<Output>
) async throws -> Output Specify the VSOCK address to connect to for the
Channel
.func connect(unixDomainSocketPath: String
) -> EventLoopFuture<Channel> func connect<Output>(unixDomainSocketPath: String, channelInitializer: @escaping (Channel) -> EventLoopFuture<Output>
) async throws -> Output Specify the
unixDomainSocket
path to connect to for the UDSChannel
that will be established.func connectTimeout(TimeAmount
) -> Self Specifies a timeout to apply to a connection attempt.
func enableMPTCP(Bool
) -> Self Enables multi-path TCP support.
func protocolHandlers(@escaping () -> [ChannelHandler]
) -> Self func resolver(Resolver?
) -> Self Specifies the
Resolver
to use ornil
if the default should be used.func withConnectedSocket(NIOBSDSocket.Handle
) -> EventLoopFuture<Channel> Use the existing connected socket file descriptor.
func withConnectedSocket<Output>(NIOBSDSocket.Handle, channelInitializer: @escaping (Channel) -> EventLoopFuture<Output>
) async throws -> Output Use the existing connected socket file descriptor.
Show obsolete interfaces (1)
Hide obsolete interfaces
func withConnectedSocket(descriptor: CInt
) -> EventLoopFuture<Channel> Use the existing connected socket file descriptor.