Providing you information relating to all technicalities of UDP server. This section provides you the brief description and program of the UDP server only for received your messages or information.
The UDP server
UDP denotes a computing and technical terms that stands for User Datagram Protocol. Usually functioning as a connectionless datagram services with no guarantee of delivering data in a particular sequence. Any source host that requires a reliable communication has options of using either TCP or a program based on a sequential services. Generally all UDP messages are sent with the current IP address through ports. It helps in delivering messages from the source host to the ultimate destination as a postcard; small but not with a guarantee of delivery but TCP works like a telephone by verifying the destination address. Usually UDP is used to deliver a small amount of data to a large number of recipient at one set period of time. So it low over heading and multitasking capacity stands it ahead than TCP.
The datagram is an unite of packet or packet for transfer in the TCP/IP network. Each datagram packet has data with source and destination address.
Description of program:
When you will run the program then a layout will appear on the screen that contains two buttons 'Start' and 'Stop' with a text area, where you receive your messages. The messages can be received only on that time when the UDP server is started. Whenever the UDP server is stopped then you can't be sent any message by the UDP client. If UDP server is started then it display the the message "Server is started" in the text area otherwise it shows "Server is stopped" or no any message in the text area.
Description of code:
Thread is a constructor of Thread class. The Thread class extends the Object and implements the Runnable. It creates a new thread object. Where you require, the executing of program continuously you can be used thread.
This method starts the thread for executing the program. The run() method is called automatically when the start() method is execute.
The above method interrupts the thread that means breaking the thread for some time. If you want to start the thread again you can start it.
DatagramSocket is the constructor of DatagramSocket class. This class extends Object. It creates the datagram socket and takes only integer port number. This socket binds the specified port number where the messages is send on the local host machine.
This method is used to insert or append given the string in it.
DatagramPacket(byte buffer, int buffer_length):
This constructor provided by the DatagramPacket class. This class extends the Object and imports the java.net.*. It constructs a DatagramPacket to the receiving packet length. It takes the buffer size and buffer length. Where the connectionless services are provided by the user then use it.
The datagram packet received by this method from the specified socket.
This class extends the Object and implements the Serializable. It displays the IP address.
Above method returns the IP address of the object of InetAddress class, where the datagram packet can be send or receive.
This method returns the port number of the host machine. Where the datagram packets can be send or receive.
This method closes the datagram socket that means you can not be received any messages.
Here is the code of program:
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: April 17, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles