I`ve developed a midlet to submit a score to a server and get back a response- ok, failed etc.
Below is the loop which connects to the url. It all runs fine on Nokias but throws a IOException when run
on Sony Ericsson (K700i) and Motorola (V3,V525,V500).
It seems to be thrown when the in = hc.openDataInputStream(); call is made.
When i attempt to connect, i get the screen asking whether i should allow the connection and then it fails.
Can anyone help??
I am unsure as to which hc.setRequestProperty to set. Could this be effecting it?
The url is a WAP page.
public void run()
{
while(running)
{
HttpConnection hc = null
InputStream in = null;
OutputStream out = null;
StringBuffer b= new StringBuffer();
try
{
hc = (HttpConnection)Connector.open(url);
hc.setRequestMethod(HttpConnection.GET);
//hc.setRequestProperty(" Content-Type" ," application/x-www-form-urlencoded" );
//hc.setRequestProperty( " User-Agent" , agent );
//hc.setRequestProperty( " Content-Type" , type );
//hc.setRequestProperty( "Content-Length" , Integer.toString(url.length()) );
out = hc.openOutputStream();
in = hc.openDataInputStream();
int ch;
System.out.println(" Responed= " );
while((ch=in.read()) != -1){
b.append((char)ch);
System.out.println((char)ch);
}
doSomething(b);
}
catch (ConnectionNotFoundException cnfe){System.out.println(cnfe);}
catch (IOException ie){ System.out.println(ie);}
finally
{
running=false;
try
{
if(in!=null) in.close();
if(hc!=null) hc.close();
if(out!=null) out.close();
}
catch(IOException ie){System.out.println(ie);}
}
}
}