Monday, January 23, 2017

Ping on client side

I am trying to use the code in my client code

public PingObj pingUrl(final String address) {
PingObj po = new PingObj();
try {
final URL url = new URL("http://" + address);
po.setAddress(url.toString());
final HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
urlConn.setConnectTimeout(1000 * 10); // mTimeout is in seconds
final long startTime = System.currentTimeMillis();
po.setStartTime(startTime);
urlConn.connect();
final long endTime = System.currentTimeMillis();
po.setEndTime(endTime);
if (urlConn.getResponseCode() == HttpURLConnection.HTTP_OK) {
System.out.println("Time (ms) : " + (endTime - startTime));
System.out.println("Ping to " + address + " was success");
po.setSuccess(true);
po.setTimeTaken(endTime - startTime);
return po;
}
} catch (final Exception e1) {
e1.printStackTrace();
po.setSuccess(false);
}
return po;
}

which uses java.net.HttpURLConnection, java.net.URL which cannot be used on the GWT Client side. I am new to this. How to handle these on client side?

Thanks in advance. 

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment