Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Others;
- import java.io.IOException;
- import java.net.*;
- public class UDP {
- public static void main(String[] args) {
- try {
- DatagramSocket datagramSocket = new DatagramSocket(6666);
- byte[] buf = new byte[1024];
- DatagramPacket packet = new DatagramPacket(buf, buf.length,
- InetAddress.getByName("192.168.8.255"), 6666);
- packet.setData("KrzysiekZ.".getBytes());
- datagramSocket.send(packet);
- } catch (SocketException e) {
- e.printStackTrace();
- } catch (UnknownHostException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement