File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
src/main/java/com/fzi/externalcontrol/impl Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 2929import java .io .DataOutputStream ;
3030import java .io .IOException ;
3131import java .io .InputStreamReader ;
32+ import java .net .InetSocketAddress ;
3233import java .net .Socket ;
3334
3435public class RequestProgram {
@@ -50,7 +51,12 @@ public String sendCommand(String command) {
5051 String result = "" ;
5152 try {
5253 // socket creation
53- Socket socket = new Socket (hostIp , portNr );
54+ Socket socket = new Socket ();
55+
56+ // 5 second timeout (make configurable?)
57+ int timeout = 5 *1000 ;
58+ socket .connect (new InetSocketAddress (this .hostIp , this .portNr ), timeout );
59+
5460 if (socket .isConnected ()) {
5561 // output stream creation
5662 DataOutputStream out = new DataOutputStream (socket .getOutputStream ());
You can’t perform that action at this time.
0 commit comments