Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    Problema nella ricezione dei pacchetti con MulticastSocket

    Buonasera,
    Ho scritto un semplice programma in Java, che prevede un Server che invia dei pacchetti (vuoti) ad un gruppo, con IP 239.0.0.1 e porta 6789.

    Server
    codice:
    
    
    codice:
    DatagramSocket socket = new DatagramSocket();
    
    
    byte[] b = new byte[1024];
    DatagramPacket dgram;
    
    
    dgram = new DatagramPacket(b, b.length,
      InetAddress.getByName("239.0.0.1"), 6789);
    
    
    System.err.println("Sending " + b.length + " bytes to " +
      dgram.getAddress() + ':' + dgram.getPort());
    
    
    while(true) 
    {
    
    System.err.print(".");
    socket.send(dgram);
    Thread.sleep(1000);
    }


    Client
    codice:
    
    
    codice:
    byte[] b = new byte[1024];
    DatagramPacket dgram = new DatagramPacket(b, b.length);
    MulticastSocket socket =
      new MulticastSocket(6789); 
    socket.joinGroup(InetAddress.getByName("239.0.0.1"));
    
    
    while(true) 
    {
    
    socket.receive(dgram);
    System.err.println("Received " + dgram.getLength() +
    " bytes from " + dgram.getAddress());
    dgram.setLength(b.length);
    }



    In locale i due programmi funzionano tranquillamente. Il problema viene quando provo a farli comunicare in rete locale. Al client, non arriva nessun pacchetto, e rimane quindi in attesa all'infinito. Ho provato a cambiare porte e IP, e a disattivare il firewall, ma il problema persiste.
    Qualche consiglio?

  2. #2
    Nessuno è in grado di aiutarmi? Intanto ieri, con virtual box, ho mandato in esecuzione il server sul S.O. ospite e il client sul S.O. virtuale, e non ha dato problemi. Può darsi che il problema sia l'altra macchina in rete?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.