Java clientserver programs
Requirements:
Write two programs to chat. Each program is playing the role of a client and a server. Name one of the MyServer.java and the other MyClient.java. This is how these programs should work:
1. Run MyServer. The program is waiting for a client. After the client is connected the program send: Hello !!
2. Run MyClient. This program receives The word: Hello !!.
The following steps are repeated until the client enters: bye.
Step I) Enter a message on the client’s console (Like: How are you server?) This message should appear on the server’s console (like: How are you server?)
Step II) Enter a message on the server’s console (like: I am good. Do you have any question client?). This message should appear on the client’s console (like: I am good. Do you have any question client?)
These two steps should be repeated until the client enters: bye.
I want it to display like this:
Server | Client |
How are you server? Enter a line for the server: I am good. Do you have any question client? No server. I have to leave Enter a line for the server: OK client | Hello !! Enter a line or bye to quit for the client: How are you server? I am good. Do you have any question client? Enter a line or bye to quit for the client: No server. I have to leave OK client Enter a line or bye to quit for the client: bye |
In this sample dialog:
Green lines are what the user enters.
Underlined sentences are what the client sends to the server.
Boldfaced italic sentences are what the server sends.
Other lines are the prompts for the user to enter.
12 years ago
Purchase the answer to view it

- myclient.java
- myserver.java