请教j2me中httpconnection的问题!

bearinmind 2003-10-19 12:52:03
对于pc,访问internet需要有ip,然后浏览器向dns提交url,
然后浏览器获得目标的ip,然后用http访问目标。
可是手机访问internet,用j2me中的httpconnection,
httpconnection.open(url),
请问url的解析是在那里进行的呢?
谁给解释一下从发送url请求到接收到目标服务器页面这个过程?
谢谢!

...全文
81 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
skygui 2003-11-11
  • 打赏
  • 举报
回复
我写了一个HttpConnection的连接测试,使用388c手机无法正确使用,请指教
private String getHttpConnection(String url) throws IOException
{

HttpConnection hc =null;
DataInputStream is=null; // hc.openInputStream();
StringBuffer str = new StringBuffer();
try
{
hc =(HttpConnection) Connector.open(url);
is = new DataInputStream(hc.openDataInputStream());

int ch;
while ((ch=is.read())!=-1)
{
str.append((char) ch);
}
}
catch(Exception e)
{
e.printStackTrace();
str.append("open Error");
}
finally
{
try
{
if (is!=null) is.close();
if (hc!=null) hc.close();
}
catch(IOException ioe)
{
ioe.printStackTrace();
str.append("close Error");
}
}
return str.toString();
}

在模拟器无法取得数据,在真机上也无法取得数据。
真机上[JAVA应用]-[设置]-[默认连接]-CMWAP和CMNET都测试过,依然无法取得数据
有些没有数据返回,有些返回的数据为<html><head><title>Error</title></head><body>The parameter is incorrect.</body></html>
url="www.abkk.com"返回上述回应
url="www.yahoo.com"则没有返回,
为什么会这样?

13,100

社区成员

发帖
与我相关
我的任务
社区描述
Java J2ME
社区管理员
  • J2ME社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧