Description of program:
Here, providing you a layout with the help of this program, which has destination IP address, destination port number, a text area and a "Send" command button. The IP address specify local host and destination port number takes a specific port number where you want to send the message. All messages written in the text area and finally click the send command button, messages are sent to the specific destination.
Description of code:
getByName(String socket):
This method identify the IP address of the host
machine (localhost) which is entered in string of this method.
getBytes():
This method returns a sequence of bytes of the
string.
DatagramPacket(byte[] message, int message_length,
InetAddress address, int pnum):
This is the constructor of DatagramPacket
class. The DatagramPacket class extends the Object and shows the datagam
packet. It creates a datagram packet for sending messages on the specified host
machine with the help of specified port number. The length of datagram packet
depends upon messages size.
socket.send(DatagramPacket packet):
It can be used to send the datagarm packet to specified socket.
Here is the code of program:
import javax.swing.*;
|
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: UDP Client in Java View All Comments
Post your Comment