The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::MDNS::Server - Perl extension for a multicast DNS server

SYNOPSIS

        use Net::MDNS::Server ':all';
        service("myhost", "10.0.0.1", 444, "perl", "tcp");
        while (1) {process_network_events}

ABSTRACT

  Advertises network services using the multicast DNS protocol, allows clients to find servers.
  May work with Apple's Rendevous software.

DESCRIPTION

Multicast DNS is a lightweight protocol designed to allow easy configuration of computers on a network. You can advertise services (like http, or ftp, or anything you make up). It also allows for dynamic port numbers since part of the response to a query is the port number the service is running on.

Multicast DNS is a UDP service that runs on port 5353.

This module monitors the network for queries and responds if it has an answer. If it doesn't, it keeps quiet. In this way multiple computers can form a sort of 'DNS cluster' without even knowing about each other.

In addition, multiple servers can run on the same machine, and they will keep out of each others way, thanks to the magic of UDP.

The upshot of this is that each application can advertise its own services to the network, reusing this module, without having to worry about colliding with other servers on the same machine.

The module Net::MDNS::Client can be used to query these services.

FUNCTIONS

Net::MDNS::Server::start()

Initialises the MDNS system. This is called automatically for you when you load the module. You don't need to call this unless you stop MDNS first.

Net::MDNS::Server::stop()

Stops the MDNS system. Right now it's the only way of removing services.

EXPORT

claim_hostname(hostname, ip)

Claim the hostname. The server will start answering requests for this hostname. Any other server that tries to get this hostname will fail. Naturally, if you get in second, you will fail to get the hostname.

The IP is in dotted decimal format.

e.g. claim_hostname("my_computer", "10.0.0.1");

service(hostname, ip, port number, service name, protocol)

Start advertising a service. The service name should be a commonly recognised one like "http" or "ssh", but you are free to make up your own. The protocol should be "tcp" or "udp".

You can use any hostname, ip address and port number that you feel like, but there aren't many good reasons to advertise services for another machine.

You may advertise as many services as you like.

e.g. service("myhostname", "1.0.0.10", "25", "smtp", "tcp")

process_network_events()

You have to call this as often as possible. If you don't call it enough, you'll start missing requests.

BUGS

Some aspects of mDNS, like adding data to the service records, are not yet supported, but are planned.

The biggie is that service() and claim_hostname() do not return pointers to the records created, so the created services cannot be deleted. I tried returning the pointers as integers but that didn't work. Any patches would be very much appreciated.

Also, the service call should probably be spilt into multiple calls that create individual records.

SEE ALSO

The multicast DNS system is still in RFC draft stage, so search the web for "multicast DNS" for more details.

AUTHOR

Jepri, <jepri@perlmonk.org<gt>

Jer, <jer@jabber.org<gt>

COPYRIGHT AND LICENSE

Copyright 2003 by Jepri (Perl and C wrappers)

Copyright 2003 by Jer (C library)

This library is free software; you can redistribute it and/or modify it under the same terms as the GPL.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 154:

You forgot a '=back' before '=head1'