Kitti Wateesatogkij
Kitti Wateesatogkij

Reputation: 1019

(Android) File download normally on one host, but 'completed immediately' on another

I'm in a hurry so I'll make this short. If needed, I'll provide more info when I get back to my PC.

I'm creating a download/upload speed test app for Android. Here's some of the code:

InetAddress Host = InetAddress.getByName(myHoseName);
Socket s = new Socket(Host,80);

//prepare data stream for each direction
            OutputStream output = s.getOutputStream();
            InputStream input = s.getInputStream();

//send command
            output.write( ("GET "+ myFilePath +" HTTP/1.0\r\n").getBytes() );
            output.write("Accept: */*\r\n".getBytes());
            output.write("\r\n".getBytes());

 while ((DownloadedByte += input.read(BufferData,0,BufferData.length)) != -1)
            {   
                //download started... bla bla bla

The problem:

I hope this info is enough to get started with the problem. My apology but I'll provide more info later, maybe tomorrow.

Thanks and talk to you soon!

Best, Kitti

Upvotes: 0

Views: 168

Answers (1)

Daniel S.
Daniel S.

Reputation: 6640

This looks very much like the download from my.testhost.com fails and therefor appears to complete immediately, although it only aborted. Check the downloaded data to rule this out.

A failure can happen due to a variety of reasons. Most likely are that either the hostname does not resolve (the lookup of the IP for the name my.testhost.com does not work), or the host is reachable only through a proxy server that you would need to configure before you can make downloads.

Upvotes: 1

Related Questions