Closed Guergeiro closed 4 years ago
To test this, you need to pass arguments that contain the MulticastPort, MulticastAddress and ServerPort. If you want two instances of the Server just run it two times and change the ServerPort so that they are different (Multicast Settings remain).
A Client is given bellow:
Integer port = 5000; String address = "230.1.1.1"; DatagramSocket socket = null; InetAddress host = null; DatagramPacket request = null; try { socket = new DatagramSocket(); host = InetAddress.getByName(address); byte message[] = "Vou enviar esta mensagem aos servidores".getBytes(); request = new DatagramPacket(message, message.length, host, port); socket.send(request); } catch (IOException e) { System.out.println(e.getMessage()); } Place p1 = new Place("3500", "Viseu"); try { PlacesListInterface p2 = (PlacesListInterface) Naming.lookup("rmi://127.0.0.1:6000/placelist"); p2.addPlace(p1); System.out.println(p2.getPlace("3500").getLocality()); } catch (MalformedURLException | RemoteException | NotBoundException e) { System.out.println(e.getMessage()); }
To test this, you need to pass arguments that contain the MulticastPort, MulticastAddress and ServerPort. If you want two instances of the Server just run it two times and change the ServerPort so that they are different (Multicast Settings remain).
A Client is given bellow: