Java application to communicate with PIC32 through RN171 wireless module

Discussion in 'Programmer's Corner' started by Rphil, Mar 31, 2014.

  1. Rphil

    Thread Starter New Member

    Oct 6, 2012
    Hi everybody. I'm writing a Java code which have to send and receive some data from an elecronic system through wireless. The connection is done with the RN-171. I'm now trying to connect to the RN-171 network and to send and receive some data. Although I can in my java code set up an ObjectOutputStream and send some data to the RN-171 properly, I can't set up an ObjectInputStream and my app launches the following exception:
    Code ( (Unknown Language)):
    2. invalid stream header: 2A48454C
    3.  at
    4.  at<init>(
    5.  at TestController.sendParametersToWirelessModule(
    6.  at TestController.main(
    The code which generates the exception is:
    Code ( (Unknown Language)):
    2.  try{
    3.  //1. creating a socket to connect to the server
    4.  requestSocket = new Socket("", 2000);
    5.  System.out.println("Connected to localhost in port 2004");
    6.  //2. get Input and Output streams
    7.  out = new ObjectOutputStream(requestSocket.getOutputStream());
    8.  out.flush();
    9.  --> in = new ObjectInputStream(requestSocket.getInputStream());
    10.  //3: Communicating with the server
    11.  sendMessage(message);          }
    (The arrow indicates the code line which generates exception)

    I cannot find a solution to this problem, could anyone help me please?
    Thank you in advance.