Java application to communicate with PIC32 through RN171 wireless module

Thread Starter

Rphil

Joined Oct 6, 2012
10
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:
Rich (BB code):
java.io.StreamCorruptedException: invalid stream header: 2A48454C
 at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:804) 
 at java.io.ObjectInputStream.<init>(ObjectInputStream.java:299) 
 at TestController.sendParametersToWirelessModule(TestController.java:44) 
 at TestController.main(TestController.java:30)
The code which generates the exception is:
Rich (BB code):
 try{
 //1. creating a socket to connect to the server
 requestSocket = new Socket("1.2.3.4", 2000);
 System.out.println("Connected to localhost in port 2004");
 //2. get Input and Output streams
 out = new ObjectOutputStream(requestSocket.getOutputStream());
 out.flush();
 --> in = new ObjectInputStream(requestSocket.getInputStream());
 //3: Communicating with the server
 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.

Regards
Filippo
 
Top