connect

fun connect(host: String, port: Int = 21, configuration: FtpConfiguration.() -> Unit = { }): Flow<FTPClient>

Establishes a connection to an FTP server specified by host and port.

If port is not specified, it defaults to 21.

configuration is a lambda that can be used to configure the connection using an instance of FtpConfiguration. This lambda is optional and can be omitted if no additional configuration is needed.

Returns a Flow that emits an instance of FTPClient once the connection has been established.

Example usage:

connect("ftp.example.com") {
credentials {
username = "username"
password = "password"
}
binary = true
}.collect { ftpClient ->
// Use the FTPClient instance
}

fun connect(configuration: FtpConfiguration): Flow<FTPClient>

Establishes a connection to an FTP server using the specified configuration.

configuration is an instance of FtpConfiguration that specifies the configuration options for the connection.

Returns a Flow that emits an instance of FTPClient once the connection has been established.

Example usage:

val configuration = FtpConfiguration("ftp.example.com").apply {
credentials {
username = "username"
password = "password"
}
binary = true
}

connect(configuration).collect { ftpClient ->
// Use the FTPClient instance
}