aggiornamento codice
This commit is contained in:
@@ -10,6 +10,13 @@ public class UDatagram {
|
||||
|
||||
static final int dim_buffer = 1024;
|
||||
|
||||
/**
|
||||
* Inizializza un DatagramSocket server in ascolto sulla porta scelta e restituisce il messaggio una volta ricevuto da remoto
|
||||
* @param porta Porta che userà il server per rimanere in ascolto
|
||||
* @return stringa contenente il messaggio ricevuto da remoto
|
||||
* @throws SocketException
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String listenString(int porta) throws SocketException, IOException {
|
||||
|
||||
DatagramSocket server = new DatagramSocket(porta);
|
||||
@@ -27,6 +34,13 @@ public class UDatagram {
|
||||
return messaggio;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inizializza un DatagramSocket lato client che trasmette il messaggio scelto all'indirizzo e alla porta passata come parametro
|
||||
* @param host Indirizzo IP del destinatario
|
||||
* @param porta Porta del server remoto in ascolto
|
||||
* @param messaggio Messaggio da trasmettere al server remoto
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void writeString(String host, int porta, String messaggio) throws IOException {
|
||||
|
||||
InetAddress destinatario = InetAddress.getByName(host);
|
||||
|
||||
Reference in New Issue
Block a user