how does isReachable work

i am quit confused about the implementation in jdk, does it try to establisha TCP connection on port 7 (Echo). thanks in advance
[142 byte] By [leon_wa] at [2007-11-27 6:05:52]
# 1
Yes
ejpa at 2007-7-12 16:52:40 > top of Java-index,Core,Core APIs...
# 2

i write a piece of code

Socket theSock = new Socket();

try {

byte[] addr = { 127, 0, 0, 1 };

InetAddress addr1 = InetAddress.getByAddress(addr);

//part1

System.out.print(addr1.isReachable(1000));

SocketAddress sockaddr = new InetSocketAddress(addr1, 7);

//part2

theSock.connect(sockaddr, 1000);

} catch (Exception e) {

e.printStackTrace();

} finally {

if (theSock != null) {

try {

theSock.close();

} catch (IOException e) {

}

}

the result is quite intresting, in part 1 Reachable told me "true" but

in part 2 thrown out an Exception "java.net.ConnectException: Connection refused: connect.." . is there any guy could tell me how could that happen. any reponse will be appreciate

leon_wa at 2007-7-12 16:52:40 > top of Java-index,Core,Core APIs...
# 3

>

> the result is quite intresting, in part 1 Reachable

> told me "true" but

> in part 2 thrown out an Exception

> "java.net.ConnectException: Connection refused:

> connect.." . is there any guy could tell me how could

> that happen. any reponse will be appreciate

If the connection is refused then the host was found aka the host was reachable.

cotton.ma at 2007-7-12 16:52:40 > top of Java-index,Core,Core APIs...
# 4
thanks, i got it
leon_wa at 2007-7-12 16:52:40 > top of Java-index,Core,Core APIs...