TestRegisterWithAttributespublic class TestRegisterWithAttributes extends Object implements RegisterListener
Constructors Summary |
---|
public TestRegisterWithAttributes(String name, int port)
System.out.println("Registration Starting");
System.out.println("Requested Name: " + name);
System.out.println(" Port: " + port);
// New code to register with TXT record begins here
TXTRecord txtRecord = new TXTRecord();
txtRecord.set("txtvers", "1");
txtRecord.set("status", "ready");
txtRecord.set("difficulty", "medium");
DNSSDRegistration r = DNSSD.register(0, DNSSD.ALL_INTERFACES,
name, "_example._tcp", null, // Name, type, and domain
null, port, // Target host and port
txtRecord, this); // TXT record and listener object
// New code to register with TXT record ends
Thread.sleep(30000); // Wait thirty seconds, then exit
System.out.println("Registration Stopping");
r.stop();
|
Methods Summary |
---|
public static void | main(java.lang.String[] args)
if (args.length > 1)
{
System.out.println("Usage: java TestRegisterWithAttributes name");
System.exit(-1);
}
else
{
try
{
// If name specified, use it, else use default name
String name = (args.length > 0) ? args[0] : null;
// Let system allocate us an available port to listen on
ServerSocket s = new ServerSocket(0);
new TestRegisterWithAttributes(name, s.getLocalPort());
}
catch (Exception e)
{
e.printStackTrace();
System.exit(-1);
}
}
| public void | operationFailed(DNSSDService service, int errorCode)
System.out.println("Registration failed " + errorCode);
| public void | serviceRegistered(DNSSDRegistration registration, int flags, java.lang.String serviceName, java.lang.String regType, java.lang.String domain)
System.out.println("Registered Name : " + serviceName);
System.out.println(" Type : " + regType);
System.out.println(" Domain: " + domain);
|
|