From dfc172909423c31952c225667e7ab454989cbc87 Mon Sep 17 00:00:00 2001 From: christian Date: Tue, 6 Apr 2021 23:19:04 +0200 Subject: [PATCH] addd several ports option --- .../src/main/java/FunctionLayer/Datahandler.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ArtificialAutism/src/main/java/FunctionLayer/Datahandler.java b/ArtificialAutism/src/main/java/FunctionLayer/Datahandler.java index bc9bd42d..7fa0d4cc 100644 --- a/ArtificialAutism/src/main/java/FunctionLayer/Datahandler.java +++ b/ArtificialAutism/src/main/java/FunctionLayer/Datahandler.java @@ -769,7 +769,11 @@ public class Datahandler { public void update_autismo_socket_msg() { try { - try (DatagramSocket serverSocket = new DatagramSocket(48477)) { + List portlists = new ArrayList<>(); + portlists.add(48477); + portlists.add(48478); + for (Integer port : portlists) + try (DatagramSocket serverSocket = new DatagramSocket(port)) { byte[] receiveData = new byte[4096]; InetAddress IPAddress = InetAddress.getByName("144.76.218.19"); DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length); @@ -779,7 +783,7 @@ public class Datahandler { sentence = sentence.replace("clientmessage:", ""); String getResponseMsg = getResponseMsg(sentence); byte[] sendData = getResponseMsg.getBytes("UTF-8"); - DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, 48477); + DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, port); serverSocket.send(sendPacket); } } catch (CustomError ex) {