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
socket = new Socket(hostname,port);
String request = "Hola";
InputStream in = socket.getInputStream ();
OutputStream out = socket.getOutputStream();
StringBuffer response = new StringBuffer();
byte b = new byte;
for (int n; (n = in.read(b)) != -1
response.append(new String(b, 0, n));
catch (IOException e)
Some body can give me and idea
Thanks a lot!