socket IO on MIDP
I opened a TCP stream connection between my MIDlet and a server. The connection is established, and what the MIDlet writes to the server is received fine, but when the server writes back an answer (a short test string), it is not picked up by the MIDlet. It waits on read forever, and if available is called on it, 0 is returned. There is no broken connection because netstat shows that this connection is still established. What could be the problem?
[465 byte] By [
myungsun] at [2007-9-26 4:13:44]

Your general idea is correct; however, if you close the stream, the peer complains the connection was aborted and won't do anything afterwards although it does finish reading. In JDK, calling instead Socket.shutdownOutput forces an EOF at the end of the stream and seems to take care of situations like this. The question is, in MIDP, you don't have anything equivalent... what to do?
yes, you do get a connection reset if you close the stream, which may be not be what you want if you want information going back and forth. In any case, I found a solution by resorting to an old-fashioned method of sending a termination character and having the receiver watch for it to terminate the read. As for Http vs. socket, if I'm writing a proprietary application authoring both the server and the MIDP client sides, isn't socket stream preferable as you can trim your data excahnge to the bare essentials without all the HTTP protocol-related extras? Also on this subject, do you know if there is some method that's considered the best way to go about having your MIDlet access a website? Is it to have a special proxy or gateway server to intermediate between the MIDlet and the website, parsing away and tailoring the web content for MID-size screens? Like chopping away at an oak tree to carve out a toothpick?
Proxy Question?
Depends which version of the midp you are using. The latest midp1.0.3 supports tunneling (of course using the http interface). There are a lot of issues with proxies and tunneling solves them. You should be able to set the conf file for proxy and it will work. Once the http connection gets to the proxy the tunneling feature will establish a connection to your end web server. Try telnet-*** to the proxy to make sure you can get to it.
socketIO Question?
As far as the original question about socketIO. Remember NOT USING the http interface on the client requires that you basically replace all that code in the server app and the midp app. So all the message headers, control chars, and so on.....
Are you using the Http servlet interface on the web server?
kmfinn at 2007-6-29 13:20:47 >
