Stack Exchange
How to send data via GET method in Socket Programming to Http server in java
I am new to Socket Programming , I have written a program to send get request via HttpURLConnection (it is working fine),  
Output I got : 
Some XML Data (ie Valid Data)  
Now i want to implement same in Socket Programming.  
        String ul = "http://www.xxxxxxxx.com/cgi-bin/yyyy.cgi?name=abcd&age=25&phone=01454575";
        URL url = new URL(ul);
        Socket cliSocket = new Socket();

        cliSocket.connect(new InetSocketAddress(url.getHost(), 80), 6000);
        bw = new BufferedWriter(new OutputStreamWriter(cliSocket.getOutputStream()));

        bw.write("GET " + url.getPath() + " HTTP/1.0\r\n");
        bw.write("Host: " + url.getHost() + "\r\n");
        bw.write("Pragma: cache\r\n");
        bw.write("Cache-Control: private, must-revalidate\r\n");
        bw.write("Content-Type: application/x-www-form-urlencoded\r\n");
        bw.write("\r\n");
        bw.flush();


        rd = new BufferedReader(new InputStreamReader(cliSocket.getInputStream()));


        serverData = new StringBuffer("");


        lineSep = System.getProperty("line.separator");
        while ((line = rd.readLine()) != null) {
            serverData.append(line);
            serverData.append(lineSep);
        }

        data = serverData.toString();  

Output I am getting is   
 HTTP/1.1 200 OK
Server: nginx
Date: Wed, 28 May 2014 09:55:25 GMT
Content-Type: text/html
Connection: close

{Error: 1}


Why are you using sockets manually instead of library functions?

@chrylis My Lead told to use only Sockets

Is this academic or for real code? If this is for real code, that's actively stupid; even without using useful libraries like Spring RestTemplate, HTTP is built into the standard Java API.

rd = new BufferedReader(new InputStreamReader(cliSocket.getInputStream())); will mangle your character encoding. you need to parse the response's content-type header

@chrylis real code, I have to follow my Lead as a beginner

So the server response with {Error: 1} whatever that means and could be a specific error message from channel_mgr_check_hoteldata.cgi.

If your work is not academic you should choose another Lead.

The content type you are defining is valid only for POST or PUT requests

@fmodos even if i remove that i am not getting output
