Client-Server Java Program (Socket Programming) - The Coding Shala
Home >> Computer Network >> Client-Server Java Program Client-Server Java Program (Socket Programming) Java Program to Send a Message from Client to Server and receive a Response back using socket programming. The first step is to run the Server.java program. Then Run Client.java program and enter the IP address and port address of the server into the Client program. Java Code of Server.Java: import java.io. * ; import java.net.ServerSocket; import java.net.Socket; public class Server { private static Socket socket; public static void main (String[] args) { try { int port = 25000 ; ServerSocket serverSocket = new ServerSocket(port); System.out.println( "Server Started and listening to the port 25000" ); //Server is running always. This is done using this while(true) loop while ( true ) { //Reading the message ...