Solved

J2ME ICMP

Posted on 2004-08-19
31
774 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
 
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now