Java Forum / General / October 2005
Ping Class java
Marc van den Bogaard - 30 Sep 2005 10:20 GMT Hi all!
Does anyone know a Ping Class in Java to do a simple "ping" on a server and reading the response?
Didn't find anything usefull up to now.
Thank you in advance!
Skip - 30 Sep 2005 11:31 GMT > Hi all! > > Does anyone know a Ping Class in Java > to do a simple "ping" on a server and reading the response? > > Didn't find anything usefull up to now. In the Sun Runtime there are no APIs that expose this behaviour.
Marc van den Bogaard - 30 Sep 2005 11:41 GMT >>Hi all! >> [quoted text clipped - 4 lines] > > In the Sun Runtime there are no APIs that expose this behaviour. In the meantime I found out, that Java doesn't support Raw Sockets which are necessary to do such a ICMP ECHO (Ping).
But you can use Native C Code. Calling the native code using the JNI interface. The finishing touch is to wrap the JNI call in an RMI class.
Thats the theory...
Thomas Fritsch - 30 Sep 2005 12:19 GMT Skip schrieb:
>>Hi all! >> [quoted text clipped - 4 lines] > > In the Sun Runtime there are no APIs that expose this behaviour. Since Java 1.5 there is a ping-like method in java.net.InetAddress: public boolean isReachable(int timeout) <http://java.sun.com/j2se/1.5.0/docs/api/java/net/InetAddress.html#isReachable(int)>
 Signature "Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')
Camel - 30 Sep 2005 22:54 GMT Try the following code. Hope it helps. --------------------------------------------------
import java.net.*; import java.io.*; import java.util.*;
public class pingTest {
public static void main(String[] args) {
String ip = args[0]; String pingResult = "";
String pingCmd = "ping " + ip;
try { Runtime r = Runtime.getRuntime(); Process p = r.exec(pingCmd);
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) { System.out.println(inputLine); pingResult += inputLine; } in.close();
}//try catch (IOException e) { System.out.println(e); }
}
}
> Hi all! > [quoted text clipped - 4 lines] > > Thank you in advance! Roedy Green - 30 Sep 2005 23:01 GMT >Does anyone know a Ping Class in Java >to do a simple "ping" on a server and reading the response? Ping is a very low level protocol not supported by Java. You can get the same effect probing one of the higher level protocols supported like HTTP, FTP, SMTP, NTP, NNTP...
More and more servers are ignoring ping probes.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Again taking new Java programming contracts.
gerrards8@yahoo.com - 01 Oct 2005 00:39 GMT > Hi all! > [quoted text clipped - 4 lines] > > Thank you in advance! Take a look at the nio examples: http://java.sun.com/j2se/1.5.0/docs/guide/nio/example/Ping.java
Alan Krueger - 01 Oct 2005 04:03 GMT >> Does anyone know a Ping Class in Java >> to do a simple "ping" on a server and reading the response? > > Take a look at the nio examples: > http://java.sun.com/j2se/1.5.0/docs/guide/nio/example/Ping.java Just to be clear, that doesn't implement an ICMP-based ping (echo request and response). Instead, it connects to the daytime port (port 13) at the specified host. A declining number of hosts actually support that service anymore.
E.J. Pitt - 16 Oct 2005 09:50 GMT >>> Does anyone know a Ping Class in Java >>> to do a simple "ping" on a server and reading the response? [quoted text clipped - 6 lines] > 13) at the specified host. A declining number of hosts actually support > that service anymore. Err, 'A typical implementation will use ICMP ECHO REQUESTs if the privilege can be obtained, otherwise it will try to establish a TCP connection on port 7 (Echo) of the destination host.'
Alan Krueger - 19 Oct 2005 03:27 GMT >>>> Does anyone know a Ping Class in Java >>>> to do a simple "ping" on a server and reading the response? [quoted text clipped - 10 lines] > privilege can be obtained, otherwise it will try to establish a TCP > connection on port 7 (Echo) of the destination host.' You should probably cite what you're quoting. In any event, as I stated, the sample at the URL above does not use TCP port 7, it uses TCP port 13, the 'daytime' service which seems rarely supported anymore.
A better implementation using the 'echo' service might use UDP instead, since it doesn't require a connection to be established.
E.J. Pitt - 19 Oct 2005 03:44 GMT > You should probably cite what you're quoting. Sorry, I'm quoting the Javadoc for InetAddress.isReachable(), which is what I thought we were talking about. It wasn't, but it should have been ;-)
steve - 08 Oct 2005 06:59 GMT > Hi all! > [quoted text clipped - 4 lines] > > Thank you in advance! here ya go.
steve
//this class is for testing the conectivity to a database //actually it times the connection setup time //in theory this can be used to find the closest database to the client location. //date may-09-2004 package Services;
import java.io.*;
import java.net.*;
public class Pinger { // byte[] addr1 = new byte[]{(byte)192,(byte)168,(byte)2,(byte)5};
public static long testDBConn(byte[] addr1, int port, int timeoutMs) { //pass in a byte array with the ipv4 address, the port & the max time out required long start = -1; //default check value long end = -1; //default check value long total = -1; // default for bad connection
//make an unbound socket Socket theSock = new Socket();
try { InetAddress addr = InetAddress.getByAddress(addr1);
SocketAddress sockaddr = new InetSocketAddress(addr, port);
// Create the socket with a timeout //when a timeout occurs, we will get timout exp. //also time our connection this gets very close to the real time start = System.currentTimeMillis(); theSock.connect(sockaddr, timeoutMs); end = System.currentTimeMillis(); } catch (UnknownHostException e) { start = -1; end = -1; } catch (SocketTimeoutException e) { start = -1; end = -1; } catch (IOException e) { start = -1; end = -1; } finally { if (theSock != null) { try { theSock.close(); } catch (IOException e) { } }
if ((start != -1) && (end != -1)) { total = end - start; } }
return total; //returns -1 if timeout } }
Guenter Dannhaeuser - 15 Oct 2005 14:09 GMT [...]
>//this class is for testing the conectivity to a database >//actually it times the connection setup time >//in theory this can be used to find the closest database to the client >location. [...]
> // Create the socket with a timeout > //when a timeout occurs, we will get timout exp. [quoted text clipped - 8 lines] > start = -1; > end = -1; [...]
Hi,
I´ve tried this, but apparently the timeout value is neglected. Testing a connection to a host using a timeoutMS of 300 resulted in values (end-start) > 4000 in that case. No SocketTemoutException raised. Tested with JDK1.5.0_03 and _05. Any ideas?
Thanks, guenter <gd--acm-org>
Roedy Green - 15 Oct 2005 22:46 GMT >I´ve tried this, but apparently the timeout value is neglected. There was another post recently complaining timeouts were being ignored.
Maybe that number is really just a suggested MINIMUM timeout and the actual can be much longer.
Perhaps the problem is in the OS.
Is anyone aware of experiments on this?
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Again taking new Java programming contracts.
steve - 15 Oct 2005 23:37 GMT > [...] >> //this class is for testing the conectivity to a database [quoted text clipped - 25 lines] > Thanks, > guenter <gd--acm-org> how odd!! it was cut directly from a working file.
and it is working perfectly on macs and on windows se, but then again we are on 1.4.2.
I know it works , because i use it to decide between 2 different databases, for clients internally and externally to the network.
it takes 5 reading , for 192.168.2.9, XXX.XXX.XXX.XXX, YYY.YYY.YYY.YYY, then averages out the connection times. XXX.XXX.XXX.XXX, YYY.YYY.YYY.YYY, are in different parts of the world.
if you are connected internally it connects to : 192.168.2.9 if you are external it makes a connection to either : XXX.XXX.XXX.XXX, YYY.YYY.YYY.YYY depending on the lowest latency.
it checks 192.168.2.9, first so if it was not timing out in less than 4 seconds , the client would get stuck , for 20 seconds ( 5 readings of 4 seconds).
I just tested it for a local database i got 11ms for no database i got -1
that was using //This is a test class public static void main(String[] args) {
// byte[] addr1 = new byte[]{(byte)192,(byte)168,(byte)2,(byte)5}; int port = 1521; int timeoutMs = 2000; // 2 seconds long value = testDBConn(addr1, port, timeoutMs); System.out.println(value); }
then i tested a database that i know drops some packets:, all this was in less than 3 seconds.
Debugger connected to local process. Deadlock detection is not supported by the debuggee virtual machine. 31 13 14 -1 15 15 15 15 15 15 15 14 15 -1 16 -1 15 15 16 15 16 -1 16 15 15 16 16 15 15 16 15 16 15 15 16 16 15 15 16 16 16 15 17 65 17 67 33 15 14 20 15 15 15 15 15 16 15 16 14 16 15 16 16 15 15 17 16 15 15 15 16 15 15 15 17 18 16 17 64 16 15 15 16 15 15 16 31 16 16 15 16 15 16 16 15 16 15 15 15 16 15 15 16 15 16 16 15 15 -1 27 17 15 15 16 15 16 15 16 15 14 16 16 16 58 15 19 16 16 16 17 16 17 Debuggee process paused.
Guenter Dannhaeuser - 16 Oct 2005 02:29 GMT Ok, some more testing done, I now think the problem is not the timeout being ignored, but the time for executing the connect: doing something like
[...] Socket theSock = new Socket(); start0 = System.currentTimeMillis(); theSock.connect(sockaddr, timeoutMs); end0 = System.currentTimeMillis();
theSock = new Socket(); start1 = System.currentTimeMillis(); theSock.connect(sockaddr, timeoutMs); end1 = System.currentTimeMillis(); [...]
sometimes returns big values (>4000ms) for (end0 - start0) and usually values in the expected range for (end1 - start1). Is this a problem of JIT-Compiling?
However, looking at http://java.sun.com/j2se/1.5.0/docs/guide/nio/example/Ping.java I´ve managed to get a solution that´s working for me atm, based on a thread observing finishConnect() on a SocketChannel. Please excuse any bad coding style (it´s my first week on java ;) - remarks very welcome.
-- 8< ------------------------------------------------------------- package myping;
import java.io.*; import java.net.*; import java.nio.channels.*;
public class Ping { private static int timeout; // Timeout in ms for pinging private static Target t; private static SocketChannel sc; // Representation of a ping target private static class Target { public InetSocketAddress address; public SocketChannel channel; public long connectStart; public long connectFinish = 0; public Exception failure = null; public Target(String host, int port) throws IOException { address = new InetSocketAddress(InetAddress.getByName(host), port); } public long getPing() throws IOException, InterruptedException { if (connectFinish != 0) return connectFinish - connectStart; else if (failure != null) if (failure instanceof IOException) throw (IOException) failure; else if (failure instanceof InterruptedException) throw (InterruptedException) failure; else return -2; //should not happen else return -1; //Timed out } } // Thread for connecting to target private static class connector extends Thread { private volatile boolean shutdown = false; public connector() { setName("connector"); } public void shutdown() { shutdown = true; } public void run() { for (;;) { if (shutdown) { return; } // Attempt to complete the connection sequence try { if (sc.finishConnect()) { t.connectFinish = System.currentTimeMillis(); sc.close(); return; } } catch (IOException x) { try { sc.close(); } catch (IOException xx) { t.failure = xx; } t.failure = x; } } } } public static long ping(String host, int port, int timeout) throws InterruptedException, IOException { Ping.t = new Target(host, port); Ping.timeout = timeout; // Initiate a connection sequence to the given target Ping.sc = null; // Open the channel, set it to non-blocking, initiate connect sc = SocketChannel.open(); sc.configureBlocking(false); sc.connect(t.address); // Record the time we started t.connectStart = System.currentTimeMillis(); t.channel = sc;
connector conn = new connector(); conn.start(); conn.join(timeout); conn.shutdown();
sc.close(); return t.getPing(); } public static void main(String[] args) throws InterruptedException, IOException { System.out.println(ping("123.123.123.123", 7, 500)); //host, port, timeout in ms } } -- 8< -------------------------------------------------------------
cheers, guenter. <gd--acm-org>
Roedy Green - 16 Oct 2005 05:15 GMT > start1 = System.currentTimeMillis(); > theSock.connect(sockaddr, timeoutMs); > end1 = System.currentTimeMillis(); You never showed us your code for displaying end1-start1. You may have muddled the values before displaying them.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Again taking new Java programming contracts.
Guenter Dannhaeuser - 16 Oct 2005 12:34 GMT >You never showed us your code for displaying end1-start1. You may >have muddled the values before displaying them. Ok, I´ve surrounded the measurement in steve´s class with a for-loop and output it directly:
-- 8< ---------------------------------------------------------------- import java.io.*; import java.net.*;
public class Pinger { // byte[] addr1 = new byte[]{(byte)192,(byte)168,(byte)2,(byte)5}; public static long testConn(byte[] addr1, int port, int timeoutMs) { //pass in a byte array with the ipv4 address, the port & the max time out required long start = -1; //default check value long end = -1; //default check value long total = -1; // default for bad connection //make an unbound socket Socket theSock = null; try { InetAddress addr = InetAddress.getByAddress(addr1); SocketAddress sockaddr = new InetSocketAddress(addr, port); // Create the socket with a timeout //when a timeout occurs, we will get timout exp. //also time our connection this gets very close to the real time for (int i = 0; i < 10; i++) { theSock = new Socket(); start = System.currentTimeMillis(); theSock.connect(sockaddr, timeoutMs); end = System.currentTimeMillis(); System.out.println(end - start); } } catch (UnknownHostException e) { start = -1; end = -1; } catch (SocketTimeoutException e) { start = -1; end = -1; } catch (IOException e) { start = -1; end = -1; } finally { if (theSock != null) { try { theSock.close(); } catch (IOException e) { } } if ((start != -1) && (end != -1)) { total = end - start; } } return total; //returns -1 if timeout }
public static void main(String[] args) { byte[] addr = new byte[]{(byte)123,(byte)123,(byte)123,(byte)123}; int port = 123; int timeout = 500;
for (int i = 0; i < 2; i++) { System.out.println(Pinger.testConn(addr, port, timeout)); } } } -- 8< ----------------------------------------------------------------
Output for this always is something like -- 8< ---------------------------------------------------------------- 4802 282 281 282 266 282 281 282 281 282 282 4771 282 281 282 297 282 297 266 281 282 282 -- 8< ----------------------------------------------------------------
greets, guenter. <gd--acm-org>
steve - 18 Oct 2005 23:04 GMT >> You never showed us your code for displaying end1-start1. You may >> have muddled the values before displaying them. [quoted text clipped - 103 lines] > greets, > guenter. <gd--acm-org> how odd!!. I'm normally very careful before releasing code, to ensure it is good.
I currently have this running over several hundred clients, with the results back-ended to an oracle database, and have not seen this.
Perhaps it is actually correct-!!, and you seeing , either something in the jvm or you are seeing some real latency in the network for some reason.
I have just run it over 7 different hosts in our network, from both inside and outside the net. and i cannot duplicate your problem. the only thing i see is the -1. but to get a result of 4771, 4802 ,would indicate the timer is not firing in 500ms, which would indicate a possible jvm bug,(or a service tie up, which would still be a bug) perhaps you need to pass the code to sun along with details of your setup.
the code differs in that it is actually a service finder, as opposed to a real ping, in was using it for looking for services. and originally i also passed in the port numbers.
try adding a for next delay of about 1 second , between calls, it might be a function of your firewall. trying to stop a DOS attack ( currently the code runs as fast as it can open a port, which with a single ip address looks very much like a DOS)
maybe we can get others in the group to run the code to see what their results are?
Anyway This is from a client outside our company to our server, i''ll not bore you with 7 outputs
actual ping from my system.
64 bytes from 59.37.49.52: icmp_seq=0 ttl=58 time=11.966 ms 64 bytes from 59.37.49.52: icmp_seq=1 ttl=58 time=11.721 ms 64 bytes from 59.37.49.52: icmp_seq=2 ttl=58 time=11.959 ms 64 bytes from 59.37.49.52: icmp_seq=3 ttl=58 time=11.968 ms 64 bytes from 59.37.49.52: icmp_seq=4 ttl=58 time=23.224 ms 64 bytes from 59.37.49.52: icmp_seq=5 ttl=58 time=15.842 ms 64 bytes from 59.37.49.52: icmp_seq=6 ttl=58 time=22.223 ms 64 bytes from 59.37.49.52: icmp_seq=7 ttl=58 time=44.964 ms 64 bytes from 59.37.49.52: icmp_seq=8 ttl=58 time=11.691 ms 64 bytes from 59.37.49.52: icmp_seq=9 ttl=58 time=11.458 ms 64 bytes from 59.37.49.52: icmp_seq=10 ttl=58 time=12.414 ms 64 bytes from 59.37.49.52: icmp_seq=11 ttl=58 time=11.668 ms 64 bytes from 59.37.49.52: icmp_seq=12 ttl=58 time=11.675 ms 64 bytes from 59.37.49.52: icmp_seq=13 ttl=58 time=18.756 ms 64 bytes from 59.37.49.52: icmp_seq=14 ttl=58 time=13.318 ms 64 bytes from 59.37.49.52: icmp_seq=15 ttl=58 time=12.168 ms 64 bytes from 59.37.49.52: icmp_seq=16 ttl=58 time=11.939 ms 64 bytes from 59.37.49.52: icmp_seq=17 ttl=58 time=25.141 ms 64 bytes from 59.37.49.52: icmp_seq=18 ttl=58 time=12.409 ms 64 bytes from 59.37.49.52: icmp_seq=19 ttl=58 time=11.442 ms 64 bytes from 59.37.49.52: icmp_seq=20 ttl=58 time=23.186 ms 64 bytes from 59.37.49.52: icmp_seq=21 ttl=58 time=11.643 ms 64 bytes from 59.37.49.52: icmp_seq=22 ttl=58 time=12.131 ms 64 bytes from 59.37.49.52: icmp_seq=23 ttl=58 time=21.207 ms 64 bytes from 59.37.49.52: icmp_seq=24 ttl=58 time=22.406 ms 64 bytes from 59.37.49.52: icmp_seq=25 ttl=58 time=15.277 ms 64 bytes from 59.37.49.52: icmp_seq=26 ttl=58 time=20.682 ms
from the java thingy jvm 1.4.2_09
12 40 15 15 16 15 19 16 59 27 15 16 67 15 16 16 15 63 26 17 15 18 59 15 16 15 16 34 15 24 20 16 15 61 15 15 15 16 76 27 17 17 58 15 16 15 15 67 20 16 16 64 15 16 15 15 37 -1 62 17 16 15 16 -1 15 15 60 20 17 16 -1 20 16 68 62 16 18 16 18 16 15 16 33 16 15 15 16 40 53 15 15 15 15 58 15 16 -1 16 16 -1 16 15 16 14 16 47 17 16 15 28 15 64 68 33 16 16 30 16 15 68 21 24 28 17 17 15 26 18 66 16 16 22 17 61 19 16 16 44 34 15 25 16 47 17 15 15 16 16 63 16 15 22 16 58 16 16 15 16 64 -1 23 15 16 16 17 19 67 58 17 15 15 15 16 15 16 16 76 58 16 55 13 17 65 73 19 15 15 15 17 15 15 16 -1 16 44 34 15 15 14 15 70 13 18 48 14 16 16 16 16 41 16 23 26 21 66 15 15 16 38 -1 15 59 15 15 15 15 68 14 15 16 15 60 15 16 14 17 72 18 15 18 66 15 15 16 16 68 18 15 15 15 37
Guenter Dannhaeuser - 19 Oct 2005 03:47 GMT >Perhaps it is actually correct-!!, and you seeing , either something in the >jvm or you are seeing some real latency in the network for some reason. [quoted text clipped - 4 lines] > perhaps you need to pass the code to sun along with details of your setup. >[...] Hi Steve,
problem found: the JVM is running on Windows XP with netbios over TCP/IP activated. On connect() the JVM tries to resolve the hostname (java.net.InetAddress.getHostFromNameService, getHostByAddr).
Windows tries a netbios ns query on udp port 137 with a timeout of 1500ms, ignores any ICMP "port unreachable" packages and repeats this two more times, adding up to a value of 4.5 seconds (!).
Deactivating netbios "fixes" this, but isn´t always an option ... any ideas very welcome.
Greets, guenter <gd--acm-org>
steve - 19 Oct 2005 11:45 GMT >> Perhaps it is actually correct-!!, and you seeing , either something in >> the [quoted text clipped - 19 lines] > Deactivating netbios "fixes" this, but isn´t always an option ... any > ideas very welcome. psodo code!! if(total> timeoutMs){total=-1; // were on windows? }
> Greets, > guenter <gd--acm-org> Jez, so do we file this under?: 1 a java bug. 2. a windows bug. 3. every other computer in the world is wrong.
That basically must mean that when windows is in it's internal routines that take too long, that the timeouts for the java ports are being 'missed/overlooked/swallowed', it also accounts for why it's not showing up on my windows SE . (nitbios is OFF)
Anyway, way to go !!!, on the bug hunt, did you get a packet sniffer on it, how did you find it?
we could charge for this stuff. ( this is REAL WORLD programming) ;-) ( maybe roedy can get this on his web site)
personally if i were you, I would get a bug filed with sun, or add a fix into the code so that if the ping reply is > the preset timeout value , you ignore it, and re-ping.
me, I'm scrapping off all the windows stuff in our office and moving to linux Steve
Guenter Dannhaeuser - 19 Oct 2005 14:02 GMT >Jez, so do we file this under?: >1 a java bug. [quoted text clipped - 18 lines] >me, I'm scrapping off all the windows stuff in our office and moving to linux >Steve Wondering why my gateway showed activity on udp 137, I used a Packet Analyzer (Packetyzer) on this.
Turning Netbios off: no netbios name resolution, saving 4.5s.
But still Packetyzer showed reverse-ptr DNS lookups, causing testConn() to return values > timeoutMs ... huh?
These are triggered in the ProxySelector checking wether SOCKS should be used or not. Disabling proxy support with ProxySelector.setDefault(null);
or, when creating the socket, with Socket theSock = new Socket(Proxy.NO_PROXY);
prevents these lookups, passing the calls directly to the plain socket implementation, resulting in correct timeouts.
Alternatively, using InetAddress addr = InetAddress.getByAddress(String host, byte[] addr);
e.g. with InetAddress addr = InetAddress.getByAddress(ipHost, IPAddressUtil.textToNumericFormatV4(ipHost));
where ipHost is a String in IP-Format instead of InetAddress addr = InetAddress.getByAddress(String host);
bypasses reverse lookups and also validity checking on the host string. After all, I think I´ll stick to this, it´s still more elegant and simpler than the solution with the thread observing connectFinish() on a SocketChannel I posted in e4b3l15cjaifadjupvnbbeidouktultlbf@4ax.com
Just been on bugs.java.com: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5092063 describing these problems got closed with state "fixed". So this is not a bug at all ;) It´s just bad luck and two days lost.
guenter.
steve - 22 Oct 2005 10:58 GMT >> Jez, so do we file this under?: >> 1 a java bug. [quoted text clipped - 63 lines] > > guenter. 2 days lost , well now you know you are a real programmer ;-) i've done this before.
Steve
Roedy Green - 20 Oct 2005 04:07 GMT >> problem found: the JVM is running on Windows XP with netbios over >> TCP/IP activated. On connect() the JVM tries to resolve the hostname [quoted text clipped - 3 lines] >> 1500ms, ignores any ICMP "port unreachable" packages and repeats this >> two more times, adding up to a value of 4.5 seconds (!). I have documented this at http://mindprod.com/jgloss/socket.html
The practical solution I would imagine is to put such hosts in your HOSTS file and maintain them with TweakDUN to ensure the lookup is fast.
see http://mindprod.com/jgloss/hosts.html
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Again taking new Java programming contracts.
Guenter Dannhaeuser - 20 Oct 2005 16:04 GMT On Thu, 20 Oct 2005 03:07:41 GMT, Roedy Green
>The practical solution I would imagine is to put such hosts in your >HOSTS file and maintain them with TweakDUN to ensure the lookup is >fast. Alan Krueger just also suggested this in OiC5f.488$E17.97@fe03.lga , I´ll reply here:
Problem is, that I do not know a priori which hosts I´m going to ping. I gather these from parsing a (quite big) list of ips indicating gateways that should work, but I have to test (some of) them to get a collection of working ones. I´d have my application to constantly update the lmhosts-file - not an option.
Anyway, bypassing the ProxySelector-Code (see g8ccl1lcqgn0g4g2ld8kcq13u45nasm4ji@4ax.com) works for me.
greets, guenter. <gd--acm-org>
steve - 22 Oct 2005 11:01 GMT >>> problem found: the JVM is running on Windows XP with netbios over >>> TCP/IP activated. On connect() the JVM tries to resolve the hostname [quoted text clipped - 11 lines] > > see http://mindprod.com/jgloss/hosts.html you missed throwing windows away as a possible solution ;-)
steve
Roedy Green - 23 Oct 2005 11:36 GMT >you missed throwing windows away as a possible solution ;-) The boss will say: "The customer is using windows. That's where the big market is. That's where we have to develop first. It does not matter what sh.t it is. Make it work by hook or by crook."
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Again taking new Java programming contracts.
steve - 23 Oct 2005 22:23 GMT >> you missed throwing windows away as a possible solution ;-) > > The boss will say: "The customer is using windows. That's where the > big market is. That's where we have to develop first. It does not > matter what sh.t it is. Make it work by hook or by crook." good job I do all my development on osx. Then emulate the P.C with Virtual-PC, which incidentally crashes a way lot less than a real P.C.
to be honest I have lost count of the number of winblows computers I have smashed up, normally i just do the Keyboard.
Steve
Alan Krueger - 20 Oct 2005 02:21 GMT > problem found: the JVM is running on Windows XP with netbios over > TCP/IP activated. On connect() the JVM tries to resolve the hostname [quoted text clipped - 6 lines] > Deactivating netbios "fixes" this, but isn´t always an option ... any > ideas very welcome. You could try adding that hostname with address to
%SYSTEM%\drivers\etc\hosts
and see if that speeds up your name lookup.
steve - 08 Oct 2005 07:05 GMT > Hi all! > [quoted text clipped - 4 lines] > > Thank you in advance! whoops.
heres a test case
/* //This is a test class public static void main(String[] args) { // byte[] addr1 = new byte[]{(byte)192,(byte)168,(byte)2,(byte)5}; int port = 1521; int timeoutMs = 2000; // 2 seconds long value = testDBConn(addr1, port, timeoutMs); System.out.println(value); } */
basically , you don't need to implement a "ping" , by using the java classes correctly, to get a connection reply , you have to make a connection by opening a socket.
logically if you can open a socket , the server must be connected. you do not actually have to send any data , just look for a socket connection.
steve
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|