HI All ,
I have this method in which I open a socket and then passs an XML file�and also after some processing I receive that XML file.But the problem is that the program just hangs up when while loop is executed.
I can print the System.outs until------- Message to send is-------.After that the programme just hangs
Up and doesn,t print anything after that and the while loop is also not executed.
**************************************************
String xmlResponseFileName = xmlFileName;
File xmlResponseFile = null;
Socket socket = null;
BufferedReader sin = null;
PrintWriter sout = null;
PrintWriter fout = null;
String line = null;
try {
xmlResponseFile = new File(xmlFileName);
System.out.println("XML response file is"+xmlResponseFile);
fout = new PrintWriter(new FileOutputStream(xmlResponseFile));
socket = new Socket(hostName, port);
sout = new PrintWriter(socket.getOutputStream(), true);
sin = new BufferedReader(new InputStreamReader(socket.getInputStream()));
System.out.println("Message to send is"+messageToSend);
sout.println(messageToSend);
while ((line = sin.readLine()) != null){
System.out.println("Line starting is as"+line);
fout.println(line);
}
System.out.println("After the while loop");
fout.flush();
fout.close();
sin.close();
sout.close();
socket.close();
return xmlResponseFile;
}
catch (IOException e) {
System.err.println("ERR - IPCInProcessorAccessor - sendAndReceiveMessage: IOException: " + e);
e.printStackTrace(System.err);
}
Please pull me out of this soup.
Thanks in advance.
Regards,
Sumeet.