Hi!
I need to send a text to a socket and I should receive the responde in no more than 20 second. The following code send the text ok over the socket but delay sometimes 35 second receiving the response.
It seems that not check the socket all the time and the response arrived too late.
How can I read more quick from the socket?
Here the code
try
{
socket = new Socket(hostname,port);
System.out.println("Connected!!");
String request = "Hola";
InputStream in = socket.getInputStream ();
OutputStream out = socket.getOutputStream();
writeToSocket(socket,request, out);
StringBuffer response = new StringBuffer();
byte[] b = new byte[4096];
for (int n; (n = in.read(b)) != -1

{
response.append(new String(b, 0, n));
}
System.out.println("RESPONSE: "+response.toString());
in.close();
out.close();
socket.close();
}
catch (IOException e)
{
e.printStackTrace();
}
Some body can give me and idea

Thanks a lot!
Natalia