A common way :
Create a Socket to connect the the port, if it could be connected, it means
that a program is listerening on that port.
A sample code like :
public static boolean isConnected(String hostName, int port) {
        Socket socket = null;
        try {
            socket = new Socket(hostName, port);
            return socket.isConnected();
        } catch (Exception e) {
            return false;
        } finally {
            if (socket != null)
                try {
                    socket.close();
                } catch (Exception e) {
                }
        }
    }

But first, you need to make sure to bind the correct IP, or you could not
connect it to the remote machine,
Second, you do not know which program is llsterening on the specified port,
maybe it is not Geronimo server :-(
Wish it helps you, or anyone could give more better solution.
             Ivan

2009/5/5 RickI <a...@worker.com>

>
> I start new geronimo instance by changing port-offset in configuration
> file.
> All of that port are open but I dont want to access it through web-console
> but through java code.
> I want to know if geronimo instance in port 1199 (for example) is running
> or
> not.
>
> -R
>
>
> Ivan Xu wrote:
> >
> > Which port is available for you ? I mean you could connect from the
> remote
> > machine
> >
> > 2009/5/1 RickI <a...@worker.com>
> >
> >>
> >> Yes i think it's one way to check the main/default geronimo server.
> >> But I try to check the state of geronimo instances on other port.
> >> That way might not work.
> >>
> >> Thanks,
> >>
> >> Ricky
> >>
> >>
> >> Ivan Xu wrote:
> >> >
> >> > No sure how does the wait-for-server command implement it, but I think
> >> try
> >> > to connect the server via JMX is also a way to check whether the
> kernel
> >> is
> >> > running.Ivan
> >> >
> >
> > --
> > Ivan
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Check-server-state--tp23267578s134p23378540.html
> Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
>
>


-- 
Ivan

Reply via email to