I have a following piece of code which create an http connection to www.google.com
HttpURLConnection conn = null;
boolean success = true;
conn = (HttpURLConnection) new URL(url).openConnection();
// put itmestamp here
System.out.println("read timeout = "+conn.getReadTimeout());
System.out.println("connectTimeout = " + conn.getConnectTimeout());
Here i have set connect time out manually. How do i find out exactly how much time it takes to connect.
Also i want to send some request data and receive response to calculate exactly how much time a rountrip takes.
How do i do it ?
Also same thing i want to do on a socket for which i have the following code :
SocketAddress sockaddr = new InetSocketAddress("www.google.com", 80);
Socket socket = new Socket();
System.out.println("is socket connected = " + socket.isConnected());
System.out.println("socket timeout = "+socket.getSoTimeout());
But again here i want to send something on the socket and receive some result like a ping so as to know how much time it took.