I am making an android app and sending an xml to an ip address. I should get back an xml as response but bytes in inputstream buffer is always empty. I am using following code:
String sMessage = "<Server><CONNECT><IP>192.168.1.14</IP><Client_ID>123</CLIENT_GUID></CONNECT></Server>";
Socket clientSocket = null;
clientSocket = new Socket("192.168.252.148",34543);
PrintWriter pw = new PrintWriter(clientSocket.getOutputStream(),true);
pw.write(sMessage);
InputStream in = clientSocket.getInputStream();
byte[] buffer = new byte[in.available()];
System.out.println("buffer size: "+buffer.length);
pw.close();
in.close();
clientSocket.close();
Any idea why am i not getting bytes in my inputstream. Thanks in advance.