Hi I'm trying to use the remote Sensor Protocoll in SCRATCH to connect to a simple JAVA Middleware. It's no problem to send broadcasts from SCRATCH to the middleware. But SCRATCH crashes if i try to send something from the middleware to SCRATCH.
My Java-Code looks like:
private void sendToScratch(java.net.Socket socket, String dataOut){
PrintWriter printWriter;
try {
printWriter = new PrintWriter(
new OutputStreamWriter(
socket.getOutputStream()));
byte [] sizeBytes = { 0, 0, 0, 0 };
sizeBytes[3] = (byte)dataOut.length();
System.out.println("Sende größe:"+sizeBytes[3]);
System.out.println(dataOut);
for (int i=0; i<4; i++) {
printWriter.write(sizeBytes[i]);
// TODO Auto-generated catch block
}
printWriter.write(dataOut);
printWriter.flush();
System.out.println("send");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Offline
Well, if you want me to give you a dll that does it I can.
nathansaint1@gmail.com
Offline