Question: Create Java Programs: Develop a simple Server program and a Client program using Java. - - The Client Code and the Server Code is down

Create Java Programs:
Develop a simple Server program and a Client program using Java. -- The Client Code and the Server Code is down below. The Client program should send a personal message to the Server. Make sure the Client program is displaying the command prompt with the sent message visible.
Code Explanation: For each line of code in your Server and Client programs, add comments explaining what the line does.
Enhancing Server Functionality:
Server Setup; Modify your Server program to act as a mailbox.
The server should continuously accept requests from an open Socket.
Message Handling: Implement functionality for the server to parse incoming messages and execute the appropriate method based on the message content. (You can decide how to implement this.)
Message Storage: Save messages from clients in the following scenarios:
Without knowing the addressee or addresser.
Knowing only the addressee.
Knowing both the addressee and addresser.
Client Interaction: Implement a feature where the server makes the sender wait until another client connects. (This feature can be left as a placeholder for now.)
Memory Management: package SocketStuff;
import java.io.BufferedReader;
public class Client {
public static void main(String[] args) throws IOException {
InputStream in = null;
BufferedReader bin = null;
Socket sock = null;
try {
sock = new Socket("127.0.0.1",5155);
in = sock.getInputStream();
bin = new BufferedReader(new InputStreamReader(in));
String line;
while((line = bin.readLine())!= null){
System.out.println(line);
}
}catch(IOException ioe){
System.err.println(ioe);
}finally {
if(sock != null){
sock.close();
}
}
Problems
@ Javadoc
Declaration
Console
Coverage
Decide on the memory capacity of your server:
Limited memory: The server can only store a certain number of messages.
Endless memory: The server can store an unlimited number of messages.
SOCKET PROGRAM: import java.net .*;
import java.io .*;
public class DateServer
public static void main(String[] args){
try {
ServerSocket sock = new ServerSocket(6013);
/* now listen for connections */
while (true){
Socket client = sock.accept();
PrintWriter pout = new
PrintWriter(client.getOutputStream(), true);
/* write the Date to the socket */
pout.println(new java.util.Date().toString());
/* close the socket and resume */
/* listening for connections */
client.close();
catch (I0Exception ioe){
System.err.println(ioe);
}
}
}
Create Java Programs: Develop a simple Server

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!