December 2015
Intermediate to advanced
292 pages
6h 16m
English
The UDP client/server applications are similar in structure to the structure used for TCP client/server applications. On the server side, a UDP server socket is created, which waits for client requests. The client will create a corresponding UDP socket and use it to send a message to the server. The server can then process the request and send back a response.
A UDP client/server will use the DatagramSocket class for the socket and a DatagramPacket to hold the message. There is no restriction on the message's content type. In our examples, we will be using a text message.
Our server is defined next. The constructor will perform the work of the server:
public class UDPServer { public UDPServer() { System.out.println("UDP ...Read now
Unlock full access