Solved

J2ME ICMP

Posted on 2004-08-19
31
789 Views
Last Modified: 2013-11-23
Hi,

does anyone know or have the code how to realize a Standard Ping to a webserver using J2ME and get delay times, etc.?
0
Comment
Question by:muaddib33
  • 14
  • 8
  • 4
  • +1
31 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 11839320
Short answer, you can't...  MIDP only supports HTTP connections, not ICMP
0
 
LVL 35

Assisted Solution

by:TimYates
TimYates earned 170 total points
ID: 11839337
Long answer, you can do something like this:

http://java.sun.com/developer/J2METechTips/2001/tt0529.html

and send "ping" your servlet on your webapp, which will return "pong", and you can work out how long it took with System.currentTimeMillis() ;

:-)
0
 
LVL 35

Expert Comment

by:girionis
ID: 11839410
You can't even do a pure ping in standard or enterprise java.
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 35

Expert Comment

by:TimYates
ID: 11839440
I know...  I'm not sure why it's never been added :-(
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11839452
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11839459
Ooops...

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4727550

it's partially in...  looks like you can ping in 1.5, but not do raw socket access (yet)
0
 
LVL 35

Expert Comment

by:girionis
ID: 11839499
Nice one, so they are going to (or have already done so) implement "ping" and advanced and raw socket support :)
0
 
LVL 35

Expert Comment

by:girionis
ID: 11839510
> but not do raw socket access (yet)

Yes true, although the state is in progress so soon (hopefully) we might have that too :)
0
 

Author Comment

by:muaddib33
ID: 11839525
Hmm...but there must be someway with low-level network programming to use Socket or DatagraConnections to ping any webserver.....
but I just don't know how to start ;)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11839549
Did you look at that first link I sent you?

http://java.sun.com/developer/J2METechTips/2001/tt0529.html

> Hmm...but there must be someway with low-level network programming to use Socket or DatagraConnections to ping any webserver.....

Nope...  You can try to connect to it, and catch the timeout...  That's about it...
0
 
LVL 35

Expert Comment

by:girionis
ID: 11839553
You can use a socket but it won't be a real ping. Ping uses ICMP packets to do it. I think the best way would be Tim's second comment.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11839556
0
 
LVL 35

Accepted Solution

by:
girionis earned 80 total points
ID: 11839582
If you want to *simulate* ping that's how you could do it: http://www.jadcentral.com/newscentral/feature.jsp?feature_ID=49
0
 

Author Comment

by:muaddib33
ID: 11839589
Yes I had a look at the article. The problem is that I want to ping standard webservers and not a server with a running servlet i would programm....
but it seems that isn't possible then ;).

thanx
0
 
LVL 35

Expert Comment

by:girionis
ID: 11839590
>  that's how you could do it

should be

that's *also* how you could do it
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11839637
>  If you want to *simulate* ping that's how you could do it: http://www.jadcentral.com/newscentral/feature.jsp?feature_ID=49

Wouldn't work on our website though, as all ports but 80 are blocked by the firewall...
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11839639
(and the echo port is turned off)

;-)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11882598
I think girionis and I pretty much covered this one...
0
 
LVL 20

Expert Comment

by:Venabili
ID: 11882727
Tim,

Read my comment :) It is an early attempt to wake up the Asker, not the experts ;))

Venabili
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11882756
Hehehe, I know ;-)  Just impatient....21 days is too long ;-)  
0
 

Author Comment

by:muaddib33
ID: 11882819
Sorry - was abroad the last days.
As I want to ping any Web-Servers there doesn't seem to be a solution for realizing this with J2ME.

regards
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11882849
Nope, as we said, you cannot do ICMP "ping" with Java -- either with J2SE, or with J2EE or with J2ME

It has limited support in the new beta J2SE 1.5, but still not in J2ME...  Maybe in the future?  MIDP 3.0?

But I doubt it will arrive for some time...

Tim
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11882855
:-(

bah...

:-(
0
 
LVL 20

Expert Comment

by:Venabili
ID: 11882909
Tim,

That is why I started to wake up Asker earlier. So far - it works :)

muaddib33,
Thanks for returning and closing the question. And sorry that the answer is "No way" :( Sometimes it happens
0
 
LVL 35

Expert Comment

by:girionis
ID: 11883008
It seems unfair to me to get all the points since Tim's answer is also valid, I'd sat valider then mine. Venabili is it ok if I post a "points" to question for Tim?
0
 

Author Comment

by:muaddib33
ID: 11884753
I don't know if there's another way to split or transfer points by now.
Otherwise reopening the question would be ok....
0
 
LVL 35

Expert Comment

by:girionis
ID: 11886362
Thank you for accepting :)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11886838
:-)  Thanks all  :-)

Good luck with it muaddib33 :-)

Tim
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
servlet filter example 37 72
by zero exception 10 54
web project error add remove 1 32
jsp error 6 27
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question