I prefer to use a java.net.Socket.

Socket s = new Socket(ip, port);

OutputStream theOutput = s.getOutputStream();
OutputStreamWriter out = new OutputStreamWriter(theOutput);

out.write(header);
out.write("\r\n");
out.write(content);

out.flush();
theOutput.flush();

InputStream in = s.getInputStream();
InputStreamReader isr = new InputStreamReader(in);
BufferedReader br = new BufferedReader(isr);
String str = "";

String userInput;

while ((userInput = br.readLine()) != null) {

str += userInput + "\n";

}

On Tuesday, November 6, 2012 4:22:16 AM UTC-6, Thomas Bouron wrote:
>
> Hello.
>
> I'm facing an issue that I cannot get a rid of it. Let me explain:
> I use for my app the AndroidHttpClient to make connection to a REST 
> server. Everything works as expected except for a few of my users. At some 
> point, my code throws an SocketTimeoutException. So I search all over the 
> web and I found that it seems to be related to the DNS lookup. The solution 
> to counter part is to use HttpURLConnection.
>
> Now the funny part: On the emulator at home, everything is fine, 
> impossible to reproduce the issue. But on the emulator at work (behind a 
> transparent proxy) I got a really weird behavior. Sometimes it works, 
> sometimes not. Event if I change the AndroidHttpClient 
> to HttpURLConnection, I got the same result. Increasing the timeout doesn't 
> solve the problem either, it just increase the time before reaching 
> the SocketTimeoutException. Regarding to my research, i also tried to 
> change the URL by the IP of the REST server but nothing changed.
>
> So now I got any idea left, that's why I'm posting here. Is anyone already 
> caught that?
>
> Thanks in advance.
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to