|
是不是说MIDP1.0实现了SOCKET的功能,只是没有把接口提供给开发者使用啊? 谁能介绍一下SOCKET是大概是怎么实现的? |
|
|
|
你需要一个WEB CGI做代理,或干脆自己写一个SERVER来处理。
HttpConnection conn; conn = (HttpConnection)Connector.open("http://your.web.site/youcgi.bin"); |
|
|
是手机支持不支持socket,而不是midp1.0支持不支持。
|
|
|
midp1.0只支持http
|
|
|
两码事
|
|
|
不是不支持,是不让你调用
|
|
|
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. |
|
|
不用考虑啦,有兴趣可以去看看
http://expert.csdn.net/Expert/TopicView1.asp?id=2094015 后来我只好自己做一个servlet,将http转为tcp |
|
|
我写了一个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"则没有返回, 为什么会这样? |
|