Http Connection Optimal solution.
Hi to all.
I'm trying to open an http connection to google and get some results.
So far I've tested Socket + Streaming to get response and HTTPConnection.
The thing is that i'm trying to be polite , not overburden google. And try to query google through one persistent connection
publicint QueryGoogle(String arg)throws Exception{
String query = arg;
query = query.replaceAll(" ","%2B");
Socket s =new Socket("google.com",80);
PrintStream p =new PrintStream(s.getOutputStream());
p.print("GET /search?q="+query+" HTTP/1.1\r\n");
p.print("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0\r\n");
p.print("Connection: close\r\n\r\n");
InputStreamReader in =new InputStreamReader(s.getInputStream());
BufferedReader buffer =new BufferedReader(in);
String line =null;
What is the best way to do that in your opinion?

