Solved

J2ME ICMP

Posted on 2004-08-19
31
784 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
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ArrayIndexOutOfBoundException 9 81
session migration servlets 2 36
Arrays.asList  VS  ArrayList 4 58
varialbe initialization 11 33
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

770 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