java - Limited sockets to midp? -
It seems that there is some kind of limit on the socket in MIDP. I need to make a lot of connections in one server ( No consent) and with the attempt to crash in or forward my app. It crashes in the simulator and also in my real device.
To isolate the possibility of being affected by my code, I exclude the following code:
try {stream connection c; Stringbuffer sb = new stringbuffer (); C = (stream connection) connector. Open ("http://www.cnn.com.br/", connector.READ_WRITE); InputStreamReader r = new input stream provider (c.openInputStream (), "UTF-8"); Println (r.read ()); C.close (); } Hold (IOException pre) {ex.printStackTrace (); }
This code crashes in the 13th attempt.
I have tried to add 10 seconds of sleep in a little loop, and it crashes in the 13th attempt.
The accident message is:
java.io.IOException: the resource limit exceeded the TCP client socket - com.sun.midp.io.j2me.socket protocol . Ops 0 (), BCI = 0 - com.sun.mid.po.a.m.m.ac.uk.protocol.connect (), bci = 124 - com.sun.mid.po.a.g.m. I.k.pr. protocol.open (), bce = 125
while trying Inside c.close () should be enough, I'm wondering if you have other issues on it Are triggering. The code should really close the connection and finally the inputstream should end in something like this:
stream connection c = null; InputStream = Faucet; Try {StringBuffer sb = new string buffer (); C = (stream connection) connector. Open ("http://www.cnn.com.br/", connector.READ_WRITE); Is = c.openInputStream (); InputStreamReader = new InputStreamReader (is, "UTF-8"); Println (r.read ()); } Hold (IOException pre) {ex.printStackTrace (); } Finally {if (is! = Null) {try {is.close ()}; } Hold (Exception preceded by {System.out.println ("Failed to close!"); }} If (c! = Null) {try {c.close (}}} hold (exception before) {System.out.println ("failed to stop Kon!"); }}}
Comments
Post a Comment