RE: [Simpleweb-Support] How to get noticed when Simple Server goesdown ...
                
                Brought to you by:
                
                    niallg
                    
                
            
            
        
        
        
    | 
     
      
      
      From: Niall G. <nia...@an...> - 2004-05-11 09:13:09
      
     
   | 
Hi,
> If I am not mistaken, implementing simple.http.connect.SocketHandler can
> only be used after the ServerSocket accepts a connection and makes a
> Socket to handle the connection.
> 
> But what I want is, to detect whether ServerSocket is still
> listening/accepting or not. I don't think implementing
> simple.http.connect.SocketHandler would solve this because the
> ServerSocket is not accepting a connection (no Socket given to
> SocketHandler yet).
In this case what you could do is extend the ServerSocket, this may not
be the most elegant solution but it is quite easy. Try somthing like
public class MonitoredServerSocket extends ServerSocket {
   private Monitor monitor;
   public MonitoredServerSocket(Monitor monitor, int port) {
      super(port);
      this.monitor = monitor;   
   }
   public Socket accept() throws IOException {
      try {
         return super.accept();
      } catch(IOException e){
	 monitor.notifyException(this, e);
         throw e;
      }
   }
}
public interface Monitor {
  
   public void notifyException(ServerSocket sock, IOException e);
}
At least this way you can still use the ConnectionFactory without having
to recode your own connection framework.
Hope this is of use,
Niall
 |