In this section we provide a complete code of a example based on the method DatagramPacket(buffer, buffer.length) for constructs a DatagramPacket for receiving packets of length length in more generic way. First of all create a class UDPReceiver and initialize a object buffer of byte[] array. After that we call the DatagramPacket(buffer, buffer.length) method for creating a datagram packet to receive data.
Here is the code of this example:
import java.net.*;
|
Here is the Output of the Example :
| C:\roseindia>javac UDPReceiver.java C:\roseindia>java UDPReceiver Datagram packet receive. |
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Construct a DatagramPacket to receive data
Post your Comment