daily pastebin goal
23%
SHARE
TWEET

Untitled

a guest Feb 18th, 2018 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package br.edu.utfpr.ap.sisdistr.multicast;
  2.  
  3. import java.io.IOException;
  4. import java.net.DatagramPacket;
  5. import java.net.InetAddress;
  6. import java.net.MulticastSocket;
  7.  
  8. public class MulticastSender {
  9.    
  10.     InetAddress grupo;
  11.     MulticastSocket multicast;
  12.     DatagramPacket pacote;
  13.    
  14.     public MulticastSender(MulticastSocket multicast, InetAddress grupo) {
  15.         this.multicast = multicast;
  16.         this.grupo = grupo;
  17.     }
  18.    
  19.     public void sendMsg(String msg) {
  20.         try {
  21.             byte[] buffer = msg.getBytes();
  22.             pacote = new DatagramPacket(buffer, buffer.length, grupo, multicast.getLocalPort());
  23.             multicast.send(pacote);
  24.         } catch (IOException e) {
  25.             e.printStackTrace();
  26.         }
  27.     }
  28.    
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top