System.out.println("Please enter some text here");
mySocket = newDatagramSocket(888);
To compile the UDPServerEx.java file:
Note: The path may vary according to where you save file.
Creating the ClientProgram
Let’s create a client class, named UDPClient, which accepts the messages sent from the server, UDPServerEx class. The client then displays the messages received in the Command Prompt. Listing 2 shows the code of the UDPClient.java file:
Use the following command to compile the UDPClient.java file:
Note: To execute the UDPServerEx and UDPClient classes, run the UDPServerEx.java and UDPClient.java in two separate Command Prompt windows. Remember, the UDPServerEx class is executed before the UDPClient class. Figure 1 shows the output of the UDP Server java and UDPClient.java files:
Showing the Output of the UDPServerEx and UDPClient Classes
Please Login to comment...