users@glassfish.java.net

Java Socket Programming issue, if Launch from Glashfish Admin Console

From: <glassfish_at_javadesktop.org>
Date: Wed, 24 Mar 2010 01:32:19 PDT

I have EAR application, the client app have simple method that use for check socket (alive or dead) :
public String checkSocket(int namaSystem,String ip, int port, int timeout)
    {
        
        String status;
        
        try
        {
            Socket socket = new Socket();
            
            socket.connect(new InetSocketAddress(ip, port), timeout);
            
            status = "alive";

            socket.close();
            return "System " + namaSystem + ", IP : " + ip + ", port : " + port + " " +status;
        }
        catch (Exception e)
        {
            System.out.println(e.getMessage());
            status = "dead";
            
            return "System " + namaSystem + ", IP : " + ip + ", port : " + port + " " +status;
        }
    }

when I run it from net bean it just works fine, the app manage to detect which socket is dead or alive, but when I launch it from Glashfish admin console (localhost:4848) it all return alive even when it shouldn't.
Its still the same EAR in the same glashfish server, but how can that happen?

GlashFish
|
+---------------------------------NetBean------------- : work
|
+----------------GlashFish admin Console----- : not work

please advice.
thanks before.
[Message sent by forum member 'eye8']

http://forums.java.net/jive/thread.jspa?messageID=393430