{"id":16889898,"url":"https://github.com/benoitc/dnssd_erlang","last_synced_at":"2025-03-22T08:31:06.661Z","repository":{"id":1362079,"uuid":"1311072","full_name":"benoitc/dnssd_erlang","owner":"benoitc","description":"Erlang interface to Apple's Bonjour DNS Service Discovery implementation","archived":false,"fork":false,"pushed_at":"2017-01-16T12:06:56.000Z","size":404,"stargazers_count":46,"open_issues_count":3,"forks_count":16,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-17T11:52:30.706Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Erlang","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/benoitc.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}},"created_at":"2011-01-31T04:20:43.000Z","updated_at":"2023-10-19T04:23:35.000Z","dependencies_parsed_at":"2022-07-29T10:39:50.393Z","dependency_job_id":null,"html_url":"https://github.com/benoitc/dnssd_erlang","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitc%2Fdnssd_erlang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitc%2Fdnssd_erlang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitc%2Fdnssd_erlang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitc%2Fdnssd_erlang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benoitc","download_url":"https://codeload.github.com/benoitc/dnssd_erlang/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244931481,"owners_count":20534007,"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":[],"created_at":"2024-10-13T16:59:41.345Z","updated_at":"2025-03-22T08:31:06.233Z","avatar_url":"https://github.com/benoitc.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"#dnssd_erlang\n\ndnssd_erlang is an interface to Apple's Bonjour DNS Service Discovery\nimplementation. Bonjour allows applications to browse, resolve and register\nnetwork services via link-local multicast DNS on the local network and via\nunicast DNS over the internet. In the later case if the service is running\nbehind a NAT gateway Bonjour will only advertise it if a port forward can be\nnegotiated via NAT-PMP or uPNP (which is attempted automatically).\n\n### Prerequisites\n\nErlang R16A or later. For compatibility with older Erlang releases use dnssd_erlang v0.8.\n\nApple Bonjour or a compatible API such as [Avahi](http://avahi.org/) with it's\ncompatibility layer along with the appropriate development files:\n\n* OS X - bundled\n* Windows - [Bonjour SDK](http://developer.apple.com/opensource/)\n* BSD/Linux - search for Avahi in your operating systems software manager\n* Ubuntu - apt-get install avahi-daemon libavahi-compat-libdnssd-dev\n\n### Build Process\n\nBuild with [rebar](https://github.com/basho/rebar):\n\n* compile: `rebar compile`\n* test: `rebar eunit`\n* edoc: `rebar doc`\n\nIf you are running Linux with Avahi you will need Avahi's Bonjour compatibility\nlayer installed. If `{error,-65537}` is returned when starting an operation\nit may be that avahi-daemon is not running.\n\nIf you are running Windows you will need Visual Studio and the Bonjour SDK\ninstalled. The project can then be built from a Visual Studio command prompt.\n\n### Example use\n\n    Eshell V5.8.2  (abort with ^G)\n    1\u003e dnssd:start().\n    ok\n\nFirst start the application via `dnssd:start/1` or `application:start(dnssd)`.\n\n### Browsing for Services\n\n    2\u003e dnssd:browse(\"_http._tcp\").\n    {ok,#Ref\u003c0.0.0.197\u003e}\n\nIn the success case, all functions return a tuple of the form `{ok, Reference}`.\nReference should be retained to pass to `dnssd:stop/1` when no further results\nare required.\n\n    3\u003e flush().\n    Shell got {dnssd,#Ref\u003c0.0.0.197\u003e,\n                     {browse,add,\n                             {\u003c\u003c\"dnsndnsweb\"\u003e\u003e,\u003c\u003c\"_http._tcp.\"\u003e\u003e,\n                              \u003c\u003c\"bonjour.tj.id.au.\"\u003e\u003e}}}\n    Shell got {dnssd,#Ref\u003c0.0.0.197\u003e,\n                     {browse,add,{\u003c\u003c\"TIVO\"\u003e\u003e,\u003c\u003c\"_http._tcp.\"\u003e\u003e,\u003c\u003c\"local.\"\u003e\u003e}}}\n    ok\n\nResults will be sent in tuples of the form\n`{dnssd, Reference, {Operation, Change, Result}}`. Reference will be the same\nreference which was used to start the operation. Operation will be one of the\natoms `browse`, `resolve`, `register` or `enumerate`. Change will be the atom\n`add` or `remove` and the result will be an operation specific term. For the\nbrowse operation, it will be a tuple containing binaries of the form\n`{ServiceName, ServiceType, Domain}`.\n\n    4\u003e dnssd:browse(\u003c\u003c\"_http._tcp\"\u003e\u003e, \u003c\u003c\"dns-sd.org\"\u003e\u003e).\n    {ok,#Ref\u003c0.0.0.488\u003e}\n    5\u003e flush().\n    Shell got {dnssd,#Ref\u003c0.0.0.488\u003e,\n                     {browse,add,\n                             {\u003c\u003c\" * Apple, makers of the iPod\"\u003e\u003e,\n                              \u003c\u003c\"_http._tcp.\"\u003e\u003e,\u003c\u003c\"dns-sd.org.\"\u003e\u003e}}}\n    Shell got {dnssd,#Ref\u003c0.0.0.488\u003e,\n                     {browse,add,\n                             {\u003c\u003c\" * Google, searching the Web\"\u003e\u003e,\n                              \u003c\u003c\"_http._tcp.\"\u003e\u003e,\u003c\u003c\"dns-sd.org.\"\u003e\u003e}}}\n    %% snipped %%\n    ok\n\nBrowsing can be limited to a specific domain by specifying the domain as\nargument two. Both domains and service types may be specified as lists or\nbinaries.\n\n### Resolving a Service Instance\n\n    6\u003e dnssd:resolve(\u003c\u003c\" * DNS Service Discovery\"\u003e\u003e, \u003c\u003c\"_http._tcp.\"\u003e\u003e, \u003c\u003c\"dns-sd.org.\"\u003e\u003e). \n    {ok,#Ref\u003c0.0.0.20357\u003e}\n\nTo resolve a service, supply it's name, registration type and domain to the\nresolve function.\n\n    7\u003e flush().\n    Shell got {dnssd,#Ref\u003c0.0.0.20357\u003e,\n                     {resolve,{\u003c\u003c\"dns-sd.org.\"\u003e\u003e,80,\n                               [{\u003c\u003c\"txtvers\"\u003e\u003e,\u003c\u003c\"1\"\u003e\u003e},{\u003c\u003c\"path\"\u003e\u003e,\u003c\u003c\"/\"\u003e\u003e}]}}}\n    ok\n\nUnlike the other operations results won't be tagged add or remove as the\nunderlying DNSSD API does not provide this information. As resolve is generally\ncalled just prior to connecting to a service this shouldn't pose a problem. The\nResult term for this operation is a tuple of the form\n`{Hostname, Port, TxtStrings}` where Hostname is a binary, Port is an integer\nand TxtStrings is a list containing either binaries or should a given string\ncontain an equals sign, a `{Key, Value}` tuple wherein Key is everything up to\nthe first equals sign and the remainder of the string is the value.\n\n    8\u003e dnssd:resolve_sync(\u003c\u003c\" * DNS Service Discovery\"\u003e\u003e, \u003c\u003c\"_http._tcp.\"\u003e\u003e, \u003c\u003c\"dns-sd.org.\"\u003e\u003e).\n    {ok,{\u003c\u003c\"dns-sd.org.\"\u003e\u003e,80,[\u003c\u003c\"txtvers=1\"\u003e\u003e,\u003c\u003c\"path=/\"\u003e\u003e]}}\n\nA synchronous wrapper to resolve is also provided. A timeout in milliseconds can\nalso be specified by adding a fourth argument. The default timeout is 5 seconds.\n`{error, timeout}` will be returned should the operation timeout.\n\n### Registering Services\n\n    9\u003e dnssd:register(\"_answer._udp\",42).\n    {ok,#Ref\u003c0.0.0.10006\u003e}\n    10\u003e flush().\n    Shell got {dnssd,#Ref\u003c0.0.0.10006\u003e,\n                     {register,add,\n                               {\u003c\u003c\"atj-mbp\"\u003e\u003e,\u003c\u003c\"_answer._udp.\"\u003e\u003e,\u003c\u003c\"local.\"\u003e\u003e}}}\n    ok\n\nThe minimum arguments needed to register a service are the service type and\nport. If no service name is supplied, the machines name is used (in the example\nabove, that's `\u003c\u003c\"atj-mbp\"\u003e\u003e`). The Result term for this operation is a tuple\ncontaining binaries of the form `{ServiceName, ServiceType, Domain}`.\n\nFor brevity, the alternative invocations of register are:\n\n    dnssd:register(Name, Type, Port).\n    dnssd:register(Type, Port, Txt).\n    dnssd:register(Name, Type, Port, Txt).\n    dnssd:register(Name, Type, Port, Txt, Host, Domain).\n\nWherein:\n\n * `Txt` is a TXT record data in either binary form (a sequence of\n`\u003c\u003cSize, String:Size/binary\u003e\u003e`), a list of atoms, strings or binaries or tuples\nof the form {Key,Value} where Key and Value are atoms, strings or binaries.\n * `Host` is the hostname of the machine running the service. Pass an empty\nstring or binary for the local machine.\n * `Domain` is the domain to register the service within. Pass an empty string\nor binary for all domains.\n\n***Note:*** A service may be renamed if it conflicts with another service. Check\nthe Results tuple to determine what name a service has been assigned.\n\n#### Local Registrations\n\nIf `localhost` is passed as Host to `dnssd:register/6` the service will be\nregistered only in the local domain (regardless of the Domain argument) and only\non the local machine.\n\n### Enumerating Domains\n\n    11\u003e dnssd:enumerate(browse).\n    {ok,#Ref\u003c0.0.0.15448\u003e}\n    12\u003e flush().\n    Shell got {dnssd,#Ref\u003c0.0.0.15448\u003e,{enumerate,add,\u003c\u003c\"local.\"\u003e\u003e}}\n    Shell got {dnssd,#Ref\u003c0.0.0.15448\u003e,{enumerate,add,\u003c\u003c\"bonjour.tj.id.au.\"\u003e\u003e}}\n    ok\n    13\u003e dnssd:enumerate(reg).\n    {ok,#Ref\u003c0.0.0.15529\u003e}\n    14\u003e flush().\n    Shell got {dnssd,#Ref\u003c0.0.0.15529\u003e,{enumerate,add,\u003c\u003c\"local.\"\u003e\u003e}}\n    Shell got {dnssd,#Ref\u003c0.0.0.15529\u003e,{enumerate,add,\u003c\u003c\"bonjour.tj.id.au.\"\u003e\u003e}}\n    ok\n\nThe Result term for this operation is a binary containing the browse or\nregistration domain.\n\n### Stopping Operations\n\nIt's important to stop operations when no more results are needed to avoid\ngenerating needless network traffic. To stop an operation pass the Reference\nreturned when you started the operation to `dnssd:stop/1`. Operations will also\nbe stopped if your process exits.\n\n### Retrieving Results\n\nResults from a running operation can be retrieved by calling\n`dnssd:results(Ref)`. For resolve operations this will only return the last\nresult. For all other operations it will return all current results.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenoitc%2Fdnssd_erlang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenoitc%2Fdnssd_erlang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenoitc%2Fdnssd_erlang/lists"}