Question: 13 14 15 16 avaSE-1.8] java F.java Client java 2 Server.java 2 l import java. 10.VatpinputStream; 2 import java.io.DataOutputStream; 3 import java.io.IOException; 4 import java.io.InputStream;
![13 14 15 16 avaSE-1.8] java F.java Client java 2 Server.java](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3cebab1860_20266f3ceba4e084.jpg)
13 14 15 16 avaSE-1.8] java F.java Client java 2 Server.java 2 l import java. 10.VatpinputStream; 2 import java.io.DataOutputStream; 3 import java.io.IOException; 4 import java.io.InputStream; 5 import java.io.OutputStream; 6 import java.net. Socket; 7 import java.util.Scanner; 8 9 public class Client { 10 public static void main(String[] args) { 11 try { 12 Socket client Socket-new Socket("localhost", 2100); // local host IP: 127.0.0.1 // Inorder to read data from a socket.. InputStrean input = client Socket.getInputStream(); // read data... Data InputStream data InputStrean - new DataInputStream(input); 17 String message= dataInputStrean.readUTF(); // get the message 18 19 System.out.println("Client: hi I get the message from the server"); 28 System.out.println(message); 21 // send data to server 22 OutputStream out= clientsocket.getOutputStream(); DataOutputStream dataOutputStream = new DataOutputStream(out); 24 25 Scanner moj - new Scanner(System.in); 26 System.out.println("Enter student name: "); 27 28 String name = myobj.nextLine(); 29 30 dataOutputStream.writeUTF (nane); 31 32 33 dataInputStream.close(); 34 input.close(); 35 clientsocket.close(); 36 37 38 } 39 catch (IOException e) { 240 // TODO: handle exception 41 System.out.println("client: "+e.getMessage()); 42 } 43 } 44] 45 23 - SE-18] erface.java ava ava java Declaration Console
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
