This should be writen in Java! Write a program that enables two users to chat. I
ID: 3817804 • Letter: T
Question
This should be writen in Java!
Write a program that enables two users to chat. Implement one user as the server (Figure 31.2la and the other as the client (Figure 31.21b). The server has two text areas: one for entering text and the other (noneditable) for displaying text received from the client. When the user presses the Enter key, the current line is sent to the client. The client has two text areas: one (noneditable) for displaying text from the server and the other for entering text. When the user presses the Enter key, the current line is sent to the server. Name the client Exercise31_09Client and the server Exercise31_09Server.Explanation / Answer
import java.net.Socket;
import java.io.*;
public class Exercise31_09Client
{
public static void main(String args[]) throws Exception
{
ServerSocket ssock = new Socket(1000);
Socket a=a.accept();
BufferedReader keyRead = new BufferedReader(new InputStreamReader(System.in));
OutputStream astream = sock.getOutputStream();
while(true)
{
if((receiveMessage = receiveRead.readLine())!= null)
{
System.out.println(receiveMessage)
}
public class Exercise31_09Server
{
public static void main(String args[]) throws Exception
{
Socket b=new ServerSocket(2000);
InputStream bstream = sock.getInputStream();
BufferedReader receiveRead = new BufferedReader(new InputStreamReader(bstream));
{
while (true)
{
System.out.println(“Exercise31_09Client”);
a=stdin.readline();
System.out.println(“Exercise31_09Server”);
b=sin.readline();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.