I searched throughout the Forums but i could not find an error like this. Also google or other search engines didnt really help me out.
The problem i have is on a Windows 7 64-bit PC. Everything is working fine (samples etc. ) and even the code posted below does what it should do (Connect to a specified NXT).
But, after i disconnect again ( comm.close(); ) and close the program,
on a new start i cannot execute this code again.
It gets me a
"Failed to connect; [10064] A socket operation failed because the destination host was down."
restarting does solve the problem, but I dont want to restart the PC again every time
The other workaround that might help finding a solution was starting the programm with an admin-console. Indeed, this helps, but only once. After that however, im able to start it from a normal console. Either way, since i use the program for several things, i dont want to do this.
Any help on this would be really appreciated. If i forgot to mention something, please ask.
The code
- Code: Select all
ConnectionReader cr = new ConnectionReader(name);
String mac = null;
try {
mac = cr.readFile();
} catch (RuntimeException e ) {
e.printStackTrace();
}
NXTInfo nxtInfo = new NXTInfo(NXTCommFactory.BLUETOOTH, name, mac);
try {
comm = NXTCommFactory.createNXTComm(NXTCommFactory.BLUETOOTH);
System.out.print(comm.available());
connected = comm.open(nxtInfo);
if (connected) { System.out.println("Connected");
output = new DataOutputStream(comm.getOutputStream());
input = new DataInputStream(comm.getInputStream());
return true;
} else {
System.out.println("Could not connect");
return false;
}
} catch (NXTCommException e) {
System.out.println("Could not connect");
System.out.println(e.getMessage());
comm.close();
throw new RuntimeException("Failure on building the Connection.")
}
}
