Pure Kotlin SMB2/SMB3 Client Library
A modern SMB client library for Kotlin, Java, and Android. Connect to Windows file shares, Samba, and NAS devices with a coroutine-based, type-safe API.
SmbClient.connect("fileserver", NtlmCredentials("user", "pass"), config = config).use { client ->
client.connectShare("documents").use { share ->
share.listDirectory("/").collect { file ->
println("${file.name} (${file.size} bytes)")
}
}
} A complete SMB client library for Kotlin and Java
Built from the ground up in Kotlin with modern APIs and zero native dependencies. Works with Windows, Samba, and any SMB2/SMB3 server.
Pure Kotlin
No JNI, no native dependencies. Runs anywhere the JVM runs — desktop, server, or Android.
SMB2 & SMB3
Full SMB2 and SMB3 protocol support with automatic version negotiation. Compatible with Windows Server, Samba, and NAS devices.
AES-128-CCM Encryption
Secure connections with SMB3 encryption, automatic or forced.
Coroutines & Flow
Async-first API built on Kotlin Coroutines. Directory listings are cold Flows.
Streaming I/O
Read and write files of any size via Okio streaming. No memory limits.
Android Ready
The only pure-Kotlin SMB client for Android. Works on API 26+ out of the box, tested on real devices.
Custom Transport
Plug in any Socket implementation. Built-in support for BlackBerry Dynamics.
Server-Side Copy
Copy files on the server without transferring data through your app.
Kotlin SMB client API examples
Real working code from the developer guide. Connect to SMB shares, read and write files — all with idiomatic Kotlin. Also works from Java.
val license = SmbLicense.fromStream(
MyApp::class.java.getResourceAsStream("/smb.lic")!!
)
val config = SmbConfig(license = license)
SmbClient.connect(
"nas.local",
NtlmCredentials("alice", "secret"),
config = config
).use { client ->
client.connectShare("shared").use { share ->
share.listDirectory("documents").collect { entry ->
val type = if (entry.isDirectory) "DIR " else "FILE"
println("$type ${entry.name} (${entry.size} bytes)")
}
}
} share.writeFile("reports/quarterly.pdf") { sink ->
val bufferedSink = sink.buffer()
File("quarterly.pdf").source().buffer().use { src ->
bufferedSink.writeAll(src)
}
bufferedSink.flush()
} class FileViewModel(private val app: Application) : AndroidViewModel(app) {
fun loadFiles(host: String, user: String, pass: String) {
viewModelScope.launch(Dispatchers.IO) {
val license = SmbLicense.fromStream(app.assets.open("smb.lic"))
val config = SmbConfig(license = license)
SmbClient.connect(host, NtlmCredentials(user, pass), config = config).use { client ->
client.connectShare("documents").use { share ->
val files = share.listDirectory("/").toList()
// Update UI state
}
}
}
}
} Java SMB library comparison
See how smb-kotlin compares to smbj and jcifs-ng — the other JVM SMB client libraries.
| Feature | smb-kotlin | smbj | jcifs-ng |
|---|---|---|---|
| Language | Kotlin | Java | Java |
| API Style | Coroutines + Flow | Blocking / CompletableFuture | Blocking |
| SMB3 Encryption | ✓ | ✗ | ✗ |
| Android Support | ✓ | Partial | Partial |
| Streaming I/O | ✓ | ✓ | ✗ |
| Custom Socket Transport | ✓ | ✗ | ✗ |
| Server-Side Copy | ✓ | ✓ | ✗ |
| Kotlin-First API | ✓ | ✗ | ✗ |
| Active Maintenance | ✓ | ✓ | Limited |
Simple, transparent pricing
Choose the plan that fits your team. All plans include the full library with every feature.
Team
5 developer licenses
- 5 developer seats
- 1 year of updates
- Priority email support
Enterprise
Unlimited developers
- Unlimited developers
- Custom terms
- Dedicated support
All purchases are subject to the License Agreement. Software is provided as-is.
Frequently asked questions about smb-kotlin
What platforms are supported?
Which SMB servers are compatible?
Does smb-kotlin work with Samba servers?
Can I use smb-kotlin from Java?
Is there an SMB client library for Android?
Do I need an internet connection for the license?
What happens when my license expires?
Can I upgrade from Solo to Team?
Is source code included?
Is there a free trial?
Try smb-kotlin free for 7 days
Fill out the form and we'll send you a 7-day trial license within 24 hours.
Thanks!
We'll review your request and send a 7-day trial license within 24 hours.
Need help?
For sales inquiries, technical support, or custom licensing, reach out and we'll get back to you within one business day.
support@ctreesoft.com