Hi I have a problem with a tcp socket.
I can send a string command to arduino ethernet shield. All is OK.
But I can't read Arduino reply (it should be "200 OK").
Always there is an exception
This is the java code used to talk to Arduino
try {
outStream.writeBytes(message);
outStream.flush();
outStream.close();
} catch (Exception ex) {
System.err.println("Unable to write " + message + " " + socket.toString()
+ ". Maybe the device is not connected.");
}
try {
inStream = new BufferedReader(new InputStreamReader(socket.getInputStream()));
System.out.print("Received string: '");
while (!inStream.ready()) {}
System.out.println(inStream.readLine()); // Read one line and output it
System.out.print("'\n");
inStream.close();
} catch(Exception e) {
System.out.print("It didn't work!\n");
}
socket.close();
}
The problem is with inStream section
Thanks