【发布时间】:2013-07-25 06:21:32
【问题描述】:
我很着急,所以我会简短地说。如果需要,我会在回到我的电脑时提供更多信息。
我正在为 Android 创建一个下载/上传速度测试应用。以下是部分代码:
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
问题:
我在 2 台主机上有相同的测试文件。 (名称为test.jpg)
一个看起来像这样:xxx.xxx.xxx.xxx(它是一个IP地址)
还有一个是像my.testhost.com这样的域名
问题是当我尝试从 xxx.xxx.xxx.xxx 下载时,一切正常
但是当我尝试从 my.testhost.com 下载时,下载过程立即完成,Logcat 上几乎没有显示任何内容
我希望这些信息足以解决问题。抱歉,我稍后会提供更多信息,也许明天。
谢谢并尽快与您联系!
最好, 小猫
【问题讨论】:
标签: android sockets http networking download