MIDP1.0不支持socket,没有socket怎么去支持http协议啊?

pascalcjava 2003-10-17 05:31:04
MIDP1.0不支持socket,没有socket怎么去支持http协议啊?
是不是说MIDP1.0实现了SOCKET的功能,只是没有把接口提供给开发者使用啊?
谁能介绍一下SOCKET是大概是怎么实现的?
...全文
110 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
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"则没有返回,
为什么会这样?
flagfly 2003-10-20
  • 打赏
  • 举报
回复
不用考虑啦,有兴趣可以去看看
http://expert.csdn.net/Expert/TopicView1.asp?id=2094015

后来我只好自己做一个servlet,将http转为tcp
szcoder 2003-10-18
  • 打赏
  • 举报
回复
不是不支持,是不让你调用
wbq1099 2003-10-18
  • 打赏
  • 举报
回复
两码事
jackwind 2003-10-18
  • 打赏
  • 举报
回复
MIDP is a specification - it defines interfaces.

There is no restriction on implementation details.

Normally, the best way to handle HTTP is use the native connection - which may not available in Java. On the other hand, even the implementor wants to disclose sockets APIs, there is no way - MIDP 1.0 simply does not define corresponding APIs. The only possible way is by optional vendor supplied APIs.
minj2me 2003-10-17
  • 打赏
  • 举报
回复
midp1.0只支持http
bb_star_bb 2003-10-17
  • 打赏
  • 举报
回复
是手机支持不支持socket,而不是midp1.0支持不支持。
hu_zy 2003-10-17
  • 打赏
  • 举报
回复
你需要一个WEB CGI做代理,或干脆自己写一个SERVER来处理。
HttpConnection conn;
conn = (HttpConnection)Connector.open("http://your.web.site/youcgi.bin");

13,100

社区成员

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

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