motorola l6 IOException
Hi im developing a application that communicate with a php server. Im using a motorola L6 as test, but the application doesn't work, when i try to establish the http connection i receive a IOException from the run method. I dont now why, also is the same in a motorola pebl u6. This is only in a real test, because in the wtk simulatorall work fine, also in the palmsim simulator. Plis help me, here is the code of the comunication part, the exception is in the public void run() method:midlet.setAlarm("Error al correr el thread:"+e.toString()) and is a java.io.IOException;
/*
* Comunicacion.java
*
* Created on April 12, 2007, 11:11 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
import java.io.*;
import javax.microedition.io.*;
/**
*
* @author DANNIEL
*/
publicclass Comunicacionimplements Runnable{
private Thread t;
private PassW midlet;
private String url="http://www.tmspan.com/midlet/passp.php",nombre="",password="";
/** Creates a new instance of Comunicacion */
public Comunicacion(PassW m){
midlet=m;
}
publicvoid conectar(String n, String p){
nombre=n;password=p;
t=new Thread(this);
try{
t.start();
}catch(Exception e){
midlet.setAlarm("Error al iniciar el thread:"+e.toString());
}
}
publicvoid run(){
try{
procesaRes();
}catch(Exception e){
midlet.setAlarm("Error al correr el thread:"+e.toString());
//System.err.println("Error:"+e.toString());
}
}
privatevoid procesaRes()throws IOException{
InputStream in=null;
OutputStream out=null;
StringBuffer respuesta=new StringBuffer();
HttpConnection conn=null;
String data="nombre="+nombre+"&password="+password;
System.out.println(data);
try{
conn=(HttpConnection) Connector.open(url);
conn.setRequestProperty("User-Agent","Profile/MIDP-2.0 Configuration/CLDC-1.0");
conn.setRequestProperty("Content-Language","es-ES");
conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
conn.setRequestProperty("Content-Length",Integer.toString(data.length()));
conn.setRequestMethod(HttpConnection.POST);
out=conn.openOutputStream();
out.write(data.getBytes());
//out.flush();
if(conn.getResponseCode() == HttpConnection.HTTP_OK){
int ch;
in=conn.openInputStream();
while( (ch = in.read()) != -1){
respuesta.append((char) ch);
}
midlet.setRespuesta(respuesta.toString());
}
else midlet.setAlarm("Servidor dice:"+conn.getResponseMessage());
// System.out.println(conn.getResponseMessage());
}catch(IOException e){
midlet.setAlarm("Error de conexion:"+e.toString());
// System.err.println("Error: " + e.toString());
}finally{
if(out!=null)out.close();
if(in!=null) in.close();
if(conn !=null) conn.close();
}
}
}

