[e-lang] Redirectories and captp://

Tyler Close list at waterken.net
Tue Sep 14 11:28:42 EDT 2004


I'm making progress on integrating VatTP with SSL and redirectories, but 
have come upon another (in a long series) of hurdles. I've got a 
solution, but it's an ugly one (also in a long series), so I was 
wondering if anyone here knows of anything better.

A Vat on a dynamic IP address must update its redirectory when the IP 
address changes. The problem is detecting this change. I was hoping that 
java.net.ServerSocket would throw an exception when the bound address 
becomes invalid, but that doesn't seem to happen. Here's the test code I 
used:

while(true)
{
     try
     {
         System.out.println("Determining local address...");
         InetAddress address = InetAddress.getLocalHost();
         System.out.println("Localhost is: " + address);
         System.out.println("Opening socket...");
         ServerSocket socket = new ServerSocket(80, 50, address);
         System.out.println("Socket open.");
         try
         {
             while(true)
             {
                 System.out.println("Listening...");
                 Socket incoming = socket.accept();
                 System.out.println("Got socket.");
                 incoming.close();
             }
         }
         catch(IOException e)
         {
             System.out.println("Socket accept error: " + e);
         }
         finally
         {
             socket.close();
         }
     }
     catch(IOException e)
     {
         System.out.println("Socket open error: " + e);
     }
}

When I release my DHCP lease, the program continues to sit on the 
java.net.ServerSocket.accept() invocation, waiting for connections it 
cannot possibly receive.

The call to java.net.InetAddress.getLocalHost() does reflect changes in 
the host IP address. So it would seem the only solution is to poll the 
host IP address. Yuck.

Does anyone know of any other API options? If not, any suggestions on 
how the polling should be implemented?

Tyler

-- 
The web-calculus is the union of REST and capability-based security.
http://www.waterken.com/dev/Web/


More information about the e-lang mailing list