Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package servermulti;
- import java.io.IOException;
- import java.net.DatagramPacket;
- import java.net.DatagramSocket;
- import java.net.InetAddress;
- import java.net.SocketException;
- import java.net.UnknownHostException;
- /**
- *
- * @author pakito
- */
- public class ServerMulti {
- static String IP = "127.0.0.1";
- public static void main(String[] args) throws SocketException, UnknownHostException, IOException, InterruptedException {
- DatagramSocket socket = new DatagramSocket();
- byte[] b = new byte[1024];
- DatagramPacket dgram;
- b = IP.getBytes();
- dgram = new DatagramPacket(b, b.length,
- InetAddress.getByName("225.0.0.1"), 6000);
- System.err.println("Sending " + b.length + " bytes to " +
- dgram.getAddress() + ':' + dgram.getPort());
- while(true) {
- System.err.print(".");
- socket.send(dgram);
- Thread.sleep(1000);
- // socket.receive(dgram);
- }
- }
- }
Add Comment
Please, Sign In to add comment