RE: [Simpleweb-Support] How to get noticed when Simple Server goesdown ...
Brought to you by:
niallg
|
From: bagas <ba...@in...> - 2004-05-11 03:57:06
|
>Hi,
>> is it running ServerSocket(80).close() would stop this server
cleanly?
> Not exactly, you need a handle on the ServerSocket given to the
> Connection.connect method. So if you did this
> ServerSocket sock = new ServerSocket(80);
> Connection.connect(sock);
> // whatever ....
> sock.close() // terminates the connection ...
Okay thank you ...
>> Supposed ServerSocket(80) crashes because of any problem, how to get
a
>> noticed when this event occur?
> You would need to write a simple.http.connect.SocketHandler to use
with
> a Connection object. You can introduce your own functionality to
handle
> failures.
> Niall
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).
I currently use code like this to check whether ServerSocket is still
listening/accepting or not!!
new Thread()
{
public void run()
{
while(true)
{
if((!sock.isBound) || sock.isClosed())
{
// do something to restart the web
server
}
Thread.sleep(5000);
}
}
}
Could you advice me better solution ?
Thank you
Best Regard,
Rahmat Bagas Santoso
|