http connection working only on Nokias?

Hello,
we have developed the MIDP1.0/CLDC1.0 midlet communicating
with the server via http connections. But we have serious troubles
with any other phones then Nokia ones because it does not communicate
at all when ran on Samsung X100, Motorola V500, T722i, S&E T610,
emulators are still OK. We have tried ‘several’ URL formats as http://www.yahoo.com/
or http://216.109.117.110:80/robots.txt but no chance to get it running.
Do you know some MIDP1.0/CLDC1.0 aps communication well? Where could be the problem?
See the code.
Best Regards
Jan Kopinec

public class HttpConnect {
public static HttpConnection c = null;
public static InputStream is = null;
public static OutputStream os = null;
public static String connect(GigaSlot midlet, String url, String stream) throws IOException {
try {
c = (HttpConnection) Connector.open(url, Connector.READ_WRITE, true);
c.setRequestMethod(HttpConnection.POST);
//c.setRequestProperty(“User-Agent”, “Profile/MIDP-1.0 Configuration/CLDC-1.0”);
c.setRequestProperty(“Content-Type”, “application/x-www-form-urlencoded”);
byte [] dat = stream.getBytes();
os = c.openOutputStream();
os.write(dat);
os.close();
os = null;
System.gc();
is = c.openInputStream();
String s = null;
int len = (int) c.getLength();
if (len > 0) {
byte[] data = new byte[len];
int actual = is.read(data);
s = new String(data);
data = null;
} else {
StringBuffer buf = new StringBuffer();
int ch;
while (((ch = is.read()) != -1) && midlet.connect) {
if(!midlet.connect) {
try {
if (is != null) {
is.close();
is = null;
}
if (c != null) {
c.close();
c = null;
}
} catch(IOException e) { }
}
buf.append((char) ch);
}
s = buf.toString();
buf = null;
System.gc();
}
if(midlet.connect) {
return s;
} else {
return “”;
}

    } finally {
        if (is != null) {
            is.close();
            is = null;
        }
        if (c != null) {
            c.close();
            c = null;
        }
    }
}

Hello. I have not tried to compile your source. However, I recognized the error problem you mentioned.

Im also developing a http POST/GET application. On my nokia 5100 it worked fine to send/receive but not using the WirelessToolkit KToolbar or Ericsson T630 / K700i.

What I had to do was handling the cookies manually. Nokia seems to take care of that automatically.

//public variable
String cookieStr="";

//Step 1: Set the cookie before posting content if you have received a cookie.
if ( cookieStr == null || cookieStr.equals("") )
{
// Ignore. No cookie reveived yet!
}
else
{
//Set the previously saved cookie…
hcon.setRequestProperty( “cookie”, cookieStr );
}

//Step 2: Get the cookie before receiving http content
String cookie=hcon.getHeaderField(“Set-cookie”);
if( cookie==null || cookie.equals("") )
{
}
else
{
cookieStr=cookie;
}

Hope this helps if it is the possible problem.

http connection works differently at different phones. at some phones you have to .flush the output stream or it will not send actually. but on nokia .flush just locks the connection. etc etc…

so i think developing micro applications that heavily rely on networking is not practical today. or you should throw away the portability issues and build different versions for different phones.

The same problem i am meeting now
I try to put a cookie to the request header
but i seens not help, why?

my server use a socketserver to receive httpconnection
the client open connection is ok and the server can receive it .but when the server try to read even a word
it throws exception: connection reset.

what the may point is ?
how can i deal it?
help