public static void main(String[] args)
{ InetAddress address = null;
Socket socket = null;
try
{
address = InetAddress.getByName("202.102.15.115");
socket = new Socket(address, 8080); if (socket.isConnected())
{
System.out.println("ok!");
}
else
{
System.out.println("fail!");
}
}
catch (Exception e)
{
e.printStackTrace();
System.out.println("fail!");
}
finally
{
if (null != socket)
{
try
{
socket.close();
}
catch (Exception e)
{
e.printStackTrace();
} } } }