Advertisement
hackmate

Untitled

May 6th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. package Others;
  2.  
  3. import java.io.IOException;
  4. import java.net.*;
  5.  
  6. public class UDP {
  7. public static void main(String[] args) {
  8. try {
  9. DatagramSocket datagramSocket = new DatagramSocket(6666);
  10. byte[] buf = new byte[1024];
  11. DatagramPacket packet = new DatagramPacket(buf, buf.length,
  12. InetAddress.getByName("192.168.8.255"), 6666);
  13. packet.setData("KrzysiekZ.".getBytes());
  14. datagramSocket.send(packet);
  15. } catch (SocketException e) {
  16. e.printStackTrace();
  17. } catch (UnknownHostException e) {
  18. e.printStackTrace();
  19. } catch (IOException e) {
  20. e.printStackTrace();
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement