Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.SocketTimeoutException;
import java.net.InetSocketAddress;
import java.net.Socket;

Expand Down Expand Up @@ -80,6 +81,8 @@ public String sendCommand(String command) {
System.out.println("hostIp is: " + this.hostIp);
System.out.println("portNr is: " + this.portNr);

// set socket timeout to 500 ms when reading from buffer
socket.setSoTimeout(500);

if (socket.isConnected()) {
// output stream creation
Expand All @@ -103,6 +106,10 @@ public String sendCommand(String command) {
out.close();
}
socket.close();
} catch (SocketTimeoutException e) {
result = String.format("popup(\"Timeout while reading requested program from " + this.hostIp + ":" + this.portNr + "\","
+ "\"Receive program failed\", False, True, blocking=True)\n"
+ "sync()", e.getMessage());
} catch (IOException e) {
result = String.format("popup(\"The connection to the remote PC at " + this.hostIp + ":" + this.portNr + " could not be established. Reason: %s\","
+ "\"Receive program failed\", False, True, blocking=True)\n"
Expand Down
Loading