View RSS Feed

Recent Blogs Posts

  1. Receiving Data via a DatagramSocket

    by , 04-25-2012 at 11:37 PM
    Data is received through a DatagramSocket by creation of the DatagramPacket firstly & then by receiving data through DatagramSocket receiver() method into it. Example is as following:
    Java Code:
    DatagramSocket datagramSocket = new DatagramSocket(80);
    byte[] buffer = new byte[10];
    DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
    datagramSocket.receive(packet);
    Way of instantiation of the DatagramSocket shall be noticed along with the parameter ...
  2. Sending Data via a DatagramSocket

    by , 04-25-2012 at 11:36 PM
    First of all DatagramPacket shall be created for sending data through DatagramSocket Java. It is done as following:
    Java Code:
    byte[] buffer = new byte[65508];
    InetAddress address = InetAddress.getByName("jenkov.com");
    DatagramPacket packet = new DatagramPacket(
        buffer, buffer.length, address, 9000);
    The byte array or byte buffer is that data which is required to be sent, in UDP datagram. Above mentioned buffer’s length (65508 bytes) is that ...
    Categories
    Tutorial