Hi!

I am developing a bluetooth message application. Sometimes it works fine, but sometimes from the client side the message is sent but i got a strange exception: java.ioException:-18, which means "NOT READY", when it invokes readInt() method from the server side.

I really need your help, becuase I really dont know what to do. I am using nokia N95 to test the application.

thank you in advance

antonio


This is the code of the server:
Code:
while (running) 
{
     StreamConnection conn = server.acceptAndOpen();
     ActiveThreadClient thread = new ActiveThreadClient(conn);
     thread.start();   
}         


class ActiveThreadClient extends Thread
{
    private StreamConnection conn;   
    public ActiveThreadClient(StreamConnection conn)
    {
            this.conn=conn;
    }
    public void run()
    {
         DataInputStream in = null;
         in = conn.openDataInputStream();    
         int lenght = in.readInt();  // here I receive the exception
         data = new byte[lenght];
         in.readFully(data);
         String string = new String(data, 0, data.length);
         ......
         ......
         ......
         in.close();
         conn.close();

    }
here there is the client code:

Code:
public boolean printJob(String data,String serverConnectionString) 
{
       
        DataOutputStream os = null;
        StreamConnection con = null;
        try 
        {
            con =(StreamConnection)Connector.open(serverConnectionString);

           os = con.openDataOutputStream();
           os.writeInt(data.getBytes().length);
           os.write(data.getBytes());
           
           os.flush();
           
           os.close();
           con.close();

        } 
        catch (IOException e2) 
        {
            
            System.out.println("Failed to print data");
            System.out.println("IOException: " + e2.getMessage());
            
            return false;
        }
       
        return true;
   }