{"id":15069140,"url":"https://github.com/appstractive/dns-sd-kt","last_synced_at":"2025-07-13T03:32:11.437Z","repository":{"id":247965733,"uuid":"827335708","full_name":"Appstractive/dns-sd-kt","owner":"Appstractive","description":"Kotlin multiplatform implemention of DNS Service Discovery","archived":false,"fork":false,"pushed_at":"2024-10-21T10:16:16.000Z","size":731,"stargazers_count":5,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-21T14:35:53.796Z","etag":null,"topics":["android","desktop","dns","dns-sd","ios","jvm","kotlin","macos","multiplatform"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Appstractive.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-11T12:59:26.000Z","updated_at":"2024-10-21T10:18:53.000Z","dependencies_parsed_at":"2024-07-11T16:11:21.960Z","dependency_job_id":"16c6c2b1-e3fe-40ff-9619-cfb4228a8196","html_url":"https://github.com/Appstractive/dns-sd-kt","commit_stats":null,"previous_names":["appstractive/dns-sd-kt"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Appstractive%2Fdns-sd-kt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Appstractive%2Fdns-sd-kt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Appstractive%2Fdns-sd-kt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Appstractive%2Fdns-sd-kt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Appstractive","download_url":"https://codeload.github.com/Appstractive/dns-sd-kt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225852726,"owners_count":17534586,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","desktop","dns","dns-sd","ios","jvm","kotlin","macos","multiplatform"],"created_at":"2024-09-25T01:40:41.135Z","updated_at":"2025-07-13T03:32:11.418Z","avatar_url":"https://github.com/Appstractive.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DNS-SD Kotlin Multiplatform\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.appstractive/dns-sd-kt?label=Maven%20Central)](https://central.sonatype.com/artifact/com.appstractive/dns-sd-kt)\n\n![badge][badge-android]\n![badge][badge-ios]\n![badge][badge-macos]\n![badge][badge-tvos]\n![badge][badge-jvm]\n\nThis library implements [Multicast DNS][mdns] and [DNS-Based Service Discovery][dnssd] to provide\nzero-configuration operations for Kotlin Multiplatform. It lets you announce and find services in a\n.local domain.\n\nThe platform implementations are based on:\n\n- Android: [Network Service Discovery (NSD)](https://developer.android.com/develop/connectivity/wifi/use-nsd)\n- Apple: [Bonjour](https://developer.apple.com/documentation/foundation/bonjour)\n- JVM: [JmDNS](https://github.com/jmdns/jmdns)\n\n## Usage\n\n### Installation\n\nGradle:\n\n```\nimplementation(\"com.appstractive:dns-sd-kt:1.0.4\")\n```\n\n### Permissions\n\n#### Android\n\nAdd the following permissions to your manifest:\n\n```Xml\n\n\u003cuses-permission android:name=\"android.permission.INTERNET\" /\u003e\n\u003cuses-permission android:name=\"android.permission.CHANGE_WIFI_MULTICAST_STATE\" /\u003e\n```\n\n#### Apple\n\nAdd the following permissions to your Info.plist (replace service type with your own):\n\n```Xml\n\n\u003ckey\u003eNSLocalNetworkUsageDescription\u003c/key\u003e\n\u003cstring\u003eRequired to discover local network devices\u003c/string\u003e\n\u003ckey\u003eNSBonjourServices\u003c/key\u003e\n\u003carray\u003e\n\u003cstring\u003e_http._tcp\u003c/string\u003e\n\u003c/array\u003e\n```\n\n### Publish a service\n\nManually:\n```kotlin\nval service = createNetService(\n  type = \"_myservice._tcp\",\n  name = \"MyService\",\n) {\n  port = 8080\n  addresses = null // platforms default addresses\n  txt =\n      mapOf(\n          \"key1\" to \"value1\",\n          \"key2\" to \"value2\",\n      )\n}\n\n// start publication to network\nservice.register()\n\nif(service.registered) {\n    // stop publication to network\n    service.unregister()\n}\n```\n\nScope based:\n```kotlin\nval scope = CoroutineScope(Dispatchers.Main) // or lifecycleScope/viewModelScope\n\nscope.launch {\n  publishService(\n      type = \"_myservice._tcp\",\n      name = \"MyService\",\n  ) {\n    port = 8080\n    addresses = null // platforms default addresses\n    txt =\n        mapOf(\n            \"key1\" to \"value1\",\n            \"key2\" to \"value2\",\n        )\n  }\n}\n\n// when the scope is cancelled, the service automatically unregisters itself\nscope.cancel()\n\n```\n\n### Discover services\n\n```kotlin\nval services: Map\u003cString, DiscoveredService\u003e = mutableMapOf()\n\ndiscoverServices(\"_myservice._tcp\").collect {\n    when (it) {\n        is DiscoveryEvent.Discovered -\u003e {\n          scannedServices[it.service.key] = it.service\n          // optionally resolve ip addresses of the service\n          it.resolve()\n        }\n        is DiscoveryEvent.Removed -\u003e {\n          scannedServices.remove(it.service.key)\n        }\n        is DiscoveryEvent.Resolved -\u003e {\n          scannedServices[it.service.key] = it.service\n        }\n    }\n}\n```\n\n## Sample App\n\nThis repository contains a sample compose multiplatform application to demonstrate the usage on the\nplatforms Android, iOS and Desktop JVM.\n\n| Android                                                                 | iOS                                                             | Desktop JVM                                                                 |\n|-------------------------------------------------------------------------|-----------------------------------------------------------------|-----------------------------------------------------------------------------|\n| \u003cimg src=\"assets/ss_android.png\" alt=\"Android Screenshot\" width=\"200\"/\u003e | \u003cimg src=\"assets/ss_ios.png\" alt=\"iOS Screenshot\" width=\"200\"/\u003e | \u003cimg src=\"assets/ss_desktop.png\" alt=\"Desktop JVM Screenshot\" width=\"200\"/\u003e |\n\n### Run\n\n#### Android\n\n```\n./gradlew installDebug\n```\n\n#### iOS\n\nOpen sample/iosApp/iosApp.xcworkspace in XCode build and run\n\n#### JVM\n\n```\n./gradlew \":sample:composeApp:run\"\n```\n\n[mdns]: https://tools.ietf.org/html/rfc6762\n\n[dnssd]: https://tools.ietf.org/html/rfc6763\n\n[badge-android]: http://img.shields.io/badge/platform-android-6EDB8D.svg?style=flat\n\n[badge-ios]: http://img.shields.io/badge/platform-ios-CDCDCD.svg?style=flat\n\n[badge-macos]: http://img.shields.io/badge/platform-macos-111111.svg?style=flat\n\n[badge-tvos]: http://img.shields.io/badge/platform-tvos-808080.svg?style=flat\n\n[badge-jvm]: http://img.shields.io/badge/platform-jvm-CDCDCD.svg?style=flat\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappstractive%2Fdns-sd-kt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappstractive%2Fdns-sd-kt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappstractive%2Fdns-sd-kt/lists"}