Guest User

Untitled

a guest
Apr 25th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package servermulti;
  6.  
  7. import java.io.IOException;
  8. import java.net.DatagramPacket;
  9. import java.net.DatagramSocket;
  10. import java.net.InetAddress;
  11. import java.net.SocketException;
  12. import java.net.UnknownHostException;
  13.  
  14. /**
  15. *
  16. * @author pakito
  17. */
  18. public class ServerMulti {
  19.  
  20.  
  21. static String IP = "127.0.0.1";
  22.  
  23.  
  24. public static void main(String[] args) throws SocketException, UnknownHostException, IOException, InterruptedException {
  25. DatagramSocket socket = new DatagramSocket();
  26.  
  27.  
  28.  
  29. byte[] b = new byte[1024];
  30. DatagramPacket dgram;
  31. b = IP.getBytes();
  32. dgram = new DatagramPacket(b, b.length,
  33. InetAddress.getByName("225.0.0.1"), 6000);
  34.  
  35.  
  36. System.err.println("Sending " + b.length + " bytes to " +
  37. dgram.getAddress() + ':' + dgram.getPort());
  38. while(true) {
  39. System.err.print(".");
  40. socket.send(dgram);
  41. Thread.sleep(1000);
  42. // socket.receive(dgram);
  43. }
  44. }
  45. }
Add Comment
Please, Sign In to add comment