ICMP in java

how can i make ping(ICMP proto) program using java,
i know i must use jni to do this,but anyone got example c code to do this?

i haven’t done much networking stuff in c, so example code or web site url would be helpfull.

AFAIK there is no way to get that far down.

If you want to ping only very special machines, maybe you can have a UDP server there and emulate ICMP with UDP?

i thought so too,but i kept googling around and found ready made jni solution for this.

here’s webpage if anyone interested http://www.geocities.com/SiliconValley/Bit/5716/ping/

JNI, of course, ALWAYS works…

You could also use Runtime.exec() to start a ping process and parse the output (whcih would be different depending on whether you were on windows or linux/unix).
See:

http://www.btinternet.com/~duncan.jauncey/old/sonar.html

Depends whether you just wanted to check whether servers were up, or do something else with icmp.

i only wanted to know if the server is up,
so the ping program from website i posted earlier had all the needed values.

i thought also about using Runtime to execute ping but this seemed good solutions as i don’t need to parse ping output(not difficult but still) and i have ready made component to do this.

but the ping jni only run’s on win platform so if i ever needed it to be running on linux,i guess i need to use runtime and parse output.i’m not that great on c socket’s.

ps.anyone know multiplatform socket api for c?

win and linux socket programming on c are quite diffrent.

?? Don’t they both have a POSIX style interface?

You are not forced to use that WSA_* stuff.

don’t know, i have always used WSA_*

and never found POSIX style example for win

well, try the POSIX examples ;D

Why wont the java dev people base all the socket stuff on some RAW class, so that we people can write our own packets? Bad, bad java devs!