title: Not getting response in socket connection
body: <p>I cannot get response in a socket connection and I couldnt understand what is wrong with the code. 
   I could able to establish a socket connection using the ip address and port number, and it is entering into </p>
  
  <pre><code>    if (nsocket.isConnected()) {} 
  </code></pre>
  
  <p>When I tried with telnet I could get the response . But the input has some other parameters like:</p>
  
  <blockquote>
    <p>POST /setMap HTTP/1.1
    Host: 192.168.1.1
    Content-Type: application/json; charset=utf-8
    Content-Length: 1234</p>
    
    <p>{ "cmd":"request_get_file_list","verification":"CVS" }</p>
  </blockquote>
  
  <p>I dont know how to include the connection properties like content type, length in my code.</p>
  
  <p>Here  is the code:</p>
  
  <pre><code>public class WebService {
  
  public static String devicelisting() {
      Socket nsocket;
  
      String response = null;
  
      try {
          nsocket = new Socket("192.168.1.1", 6666);
          if (nsocket.isConnected()) {
  
              JSONObject json = new JSONObject();
              json.put("cmd", "request_get_file_list");
              json.put("verification", "CVS");
              Log.i("AsyncTask", "doInBackground: Creating socket");
              // nsocket = new Socket();
               OutputStreamWriter out = new OutputStreamWriter(nsocket.getOutputStream(), StandardCharsets.UTF_8);
                  out.write(json.toString());
              Log.i("Webservice", "json.toString"+json.toString());
  
              InputStream in = new BufferedInputStream(nsocket.getInputStream());
              BufferedReader r = new BufferedReader(new InputStreamReader(in));
              StringBuilder stringbuilder = new StringBuilder();
              String line;
              while ((line = r.readLine()) != null) {
                  stringbuilder.append(line);
                  Log.i("line", "line.line"+line);
              }
  
  
              response = stringbuilder.toString();
              Log.i("Response", response);
          }
          else{
              Log.i("Response", "not connected");
  
          }
  
      } catch (ProtocolException e) {
          e.printStackTrace();
      } catch (MalformedURLException e) {
          e.printStackTrace();
      } catch (UnknownHostException e) {
          e.printStackTrace();
      } catch (UnsupportedEncodingException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      } catch (JSONException e) {
          e.printStackTrace();
      }
      return response;
  }
  </code></pre>
  
  <p>Please help me to find the issue. I am badly stuck up .Please help me resolve the issue</p>