Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void povoarBack_end() {
- ServerDescription s =new ServerDescription();
- ServerDescription s1=new ServerDescription();
- ServerDescription s2=new ServerDescription();
- this.DESTINATION_HOST[0]=s;
- try {
- s.monitorUDP=new MonitorUDP(this.getDatagramSocket(),s.getSocket(),s.getId());// é aqui que pára
- } catch (SocketException e) {
- e.printStackTrace();
- }
- System.out.println("Teste");
- s.monitorUDP.run();
- this.DESTINATION_HOST[1]=s1;
- try {
- s1.monitorUDP=new MonitorUDP(this.getDatagramSocket(),s1.getSocket(),s1.getId());
- } catch (SocketException e) {
- e.printStackTrace();
- }
- System.out.println("Teste");
- s1.monitorUDP.run();
- this.DESTINATION_HOST[2]=s2;
- try {
- s2.monitorUDP=new MonitorUDP(this.getDatagramSocket(),s2.getSocket(),s2.getId());
- } catch (SocketException e) {
- e.printStackTrace();
- }
- System.out.println("Teste");
- s2.monitorUDP.run();
- System.out.println("Fim");
- }
- public class MonitorUDP extends TimerTask implements Runnable {
- private static DatagramSocket datagramSocket = null;
- private static final int port = 5555;
- public String address;
- public Socket s;
- public DatagramSocket fwdS;
- Timer timer;
- private final int id;
- public MonitorUDP(DatagramSocket fwS,Socket s,int id) throws SocketException {
- this.address=s.getInetAddress().toString();
- this.fwdS=fwS;
- this.s=s;
- this.id=id;
- }
- @Override
- public void run() {
- timer = new Timer();
- timer.schedule(new Task_Monitor(fwdS,s,id),1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement