在我看來,在MIDP中創建套接字時存在某種限制。 我需要與服務器建立大量連接(不是concourrent),並在第四步或者第五步嘗試我的應用程序崩潰。它在模擬器和我真實的設備中崩潰。midp有限的插座?
要隔離它是由我的代碼影響的任何可能性,我孤立下面的代碼:
try {
StreamConnection c;
StringBuffer sb = new StringBuffer();
c = (StreamConnection) Connector.open(
"http://www.cnn.com.br/", Connector.READ_WRITE);
InputStreamReader r = new InputStreamReader(c.openInputStream(), "UTF-8");
System.out.println(r.read());
c.close();
} catch (IOException ex) {
ex.printStackTrace();
}
此代碼崩潰在13嘗試。
我tryed加10秒的睡眠,同時循環內,並且,它崩潰在13日嘗試過。
崩潰的消息是:
java.io.IOException: Resource limit exceeded for TCP client sockets
- com.sun.midp.io.j2me.socket.Protocol.open0(), bci=0
- com.sun.midp.io.j2me.socket.Protocol.connect(), bci=124
- com.sun.midp.io.j2me.socket.Protocol.open(), bci=125