Socket Programming-UDP

UDP Program to print welcome


Create 2 Files:
1)dsender.java
2)dreceiver.java

dsender.java


import java.net.*; //for java programming we have to use this package

public class dsender //class name should be name as file name
{
public static void main(String args[]) throws Exception //throws exception should be written
{
DatagramSocket ds = new DatagramSocket(); //socket will create an interface to throw/send and receive data
String str = “Welcome”;
InetAddress ip= InetAddress.getByName(“localhost”); //Inet address-> class of ip address…write ip address in place of localhost
DatagramPacket dp = new DatagramPacket(str.getBytes(),str.length(),ip,3001); //datagram packet converts string into bytes,it consists of size of string,ip address,port number
ds.send(dp);
ds.close(); //if socket is not closed it will use system resources
}
}
 
 
dreceiver.java
import java.net.*;
 
public class dreceiver
{
public static void main(String args[]) throws Exception
{
DatagramSocket ds = new DatagramSocket(3001);
byte[] buf=new byte[1024]; //creating memory space for array of bytes
DatagramPacket dp = new DatagramPacket(buf,1024); //creating a blank packet for receiving data of 1024 buffer size
ds.receive(dp); //data stored in blank packet
String str= new String(dp.getData(),0,dp.getLength()); //convert byte into string
System.out.println(str); //display output
ds.close();
}
}

OUTPUT:

145 thoughts on “Socket Programming-UDP

  1. Pingback: Google
  2. Pingback: Anal
  3. Pingback: Lawn
  4. Pingback: 188bet
  5. Pingback: app for laptop
  6. Pingback: max penis pump
  7. Pingback: webcam sex
  8. Pingback: speelgoed kopen
  9. Pingback: app for pc
  10. Pingback: couples sex toys
  11. Pingback: hamptonbaylighting
  12. Pingback: Gurgaon
  13. Pingback: cursos gratuitos
  14. Pingback: cock ring
  15. Pingback: dani best videos
  16. Pingback: webcam babes
  17. Pingback: shemale sexdate
  18. Pingback: rencontres adulte
  19. Pingback: webcambabes
  20. Pingback: anal training kit
  21. Pingback: vibrator for her
  22. Pingback: suction cup dildo
  23. Pingback: powerful vibe
  24. Pingback: sex toys
  25. Pingback: gay porn dildo
  26. Pingback: penis masturbator
  27. Pingback: vagina toy
  28. Pingback: increase penis
  29. Pingback: anal dildo
  30. Pingback: real penis dildo
  31. Pingback: Porn
  32. Pingback: gay plug
  33. Pingback: Tadapox
  34. Pingback: what are push ads
  35. Pingback: белл бой
  36. Pingback: best penis ring
  37. Pingback: squirting dildo
  38. Pingback: ben wa balls
  39. Pingback: warming rabbit
  40. Pingback: rtd principle
  41. Pingback: pleasure panty
  42. Pingback: satta matka
  43. Pingback: egg bullet
  44. Pingback: best double dildo
  45. Pingback: vagina dilator
  46. Pingback: gay bondage gear
  47. Pingback: porn
  48. Pingback: vibrating ring
  49. Pingback: vibrating penis
  50. Pingback: jockstrap brief
  51. Pingback: male stroker toy
  52. Pingback: good blow job
  53. Pingback: career
  54. Pingback: male stroker
  55. Pingback: hire a skip bin
  56. Pingback: commission
  57. Pingback: SSRU
  58. Pingback: huge dildo
  59. Pingback: rabbit vibrators
  60. Pingback: how to use a dildo
  61. Pingback: newest vibrator
  62. Pingback: sex paddles
  63. Pingback: unboxing vibrator
  64. Pingback: sexy bdsm
  65. Pingback: ps4 games
  66. Pingback: porn
  67. Pingback: huge veiny dildo
  68. Pingback: Body stockings
  69. Pingback: trixie hundeseng
  70. Pingback: Julia Ann Porn
  71. Pingback: Fashion Station
  72. Pingback: sexboer
  73. Pingback: porno files
  74. Pingback: geile sex filmpjes
  75. Pingback: gratis films
  76. Pingback: pornofilmpjes
  77. Pingback: liteblue login
  78. Pingback: u-host iptv review
  79. Pingback: liteblue
  80. Pingback: homemade dildo
  81. Pingback: porn
  82. Pingback: wanachi waterproof
  83. Pingback: virtual visa card

Leave a Reply