import java.io.*; import java.net.*; import java.nio.ByteBuffer; import java.nio.ByteOrder; class UDPClient { public static void main(String args[]) throws Exception { InetAddress localhost = InetAddress.getLocalHost(); String hostname = localhost.getHostName(); /* BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in)); */ DatagramSocket clientSocket = new DatagramSocket(); InetAddress ipAddress = InetAddress.getByName(hostname); //byte[] sendData = new byte[1024]; //byte[] receiveData = new byte[1024]; byte[] data; DatagramPacket sendPacket; //String sentence = inFromUser.readLine(); //sendData = sentence.getBytes("UTF-8"); for(int i = 0; i <= 1000000; i++) { data = ByteBuffer.allocate(4).putInt(i).array(); sendPacket = new DatagramPacket(data, data.length, ipAddress, 2345); clientSocket.send(sendPacket); //wait /* for(long j = 0; j < 1000000000; j++); for(long j = 0; j < 1000000000; j++); */ } /* DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, ipAddress, 2345); */ //clientSocket.send(sendPacket); /* DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length); */ /* clientSocket.receive(receivePacket); int rcvLen = receivePacket.getLength(); String modifiedSentence = new String(receivePacket.getData(), 0, rcvLen, "UTF-8"); System.out.println("FROM SERVER: " + modifiedSentence); */ clientSocket.close(); } }