I have a nice problem for the J2ME network developer experts.
I have a midlet running on a Nokia 6310i that opens an HTTP connection to a server and makes a couple of POST requests. The URL is retrieved by a configuration parameter in the jad and is something like http://<hostname>/cgi-bin/acgi.
Than I have two different servers, one is resolvable by name (www.funambol.com) and the other one is only know by IP address.
If I connect to the server with the hostname, everything works right. But if I try to connect to the second server, via its IP address I have a very strange behaviour. The server seems not to be contacted, but the code of the midlet is getting something from the connection, but meaningless content. Here are the first bytes received (bytes separated by '-'):
Here is the code snipped I use to make the request:
c = (HttpConnection)Connector.open(requestURL, Connector.READ_WRITE, true);
c.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0"
os = c.openOutputStream();
is = c.openInputStream();
int len = (int)c.getLength();
data = new byte[len];
len = is.read(data);
String s = "";
for (int i=0; i<len; ++i)
StaticHelper.logDB("data: " + s);
logDB() writes log messages into a persistent store so I can read it later.
In the emulator works fine....
Any thoughts? Have anybody managed to make a POST connection with the IP address in the URL?