Question: Section A: Network Programming using Java [10 Marks) 1. Following is a TCP C/S simple java program code. (5 marks each) a. Edit the client
Section A: Network Programming using Java [10 Marks) 1. Following is a TCP C/S simple java program code. (5 marks each) a. Edit the client side code to take input two integers x and y from the user and send it to server side. b. Edit the server side code to subtract (x-y) those integers and return the result (z) to client for display JAVA Client import javaje import java.net ; public class SimpleClient JAVA Server import java.io import java.net public class SimpleServes public static void main(String args[])throws IOException System.out.pdate("Client); Socket 51; si-new Socket ("127.0.0.1",8888); LoputStream siin: siin-s1.getInputStream(); DataloputStream,dis: dis-new DataloputStream siin); public static void main(String args[])throws IOException System.out.print("Server) Server Sockets snew ServerSocket(8888); Socket 1: $1 SAGREREO: OutputStream slout stout 51.getOutputStream(); DataQutruttura dos dos new DataQutputStreamSiout); loputStream siin siins1.getInputStream(); DataloputStream dis; dis new DataloputStream(siin); OutputStream slout: slout-s1.getOutputStream(); DataQutputStream dos dos-new DataQutputStream siout): Strings st-new String(disseadUTE)); System.out.printlost); ses.writeWTE"Hi there from client"); dis.desel); des.close(); slin.close(); 51.close(); des.writeUTE"Hi there from server"); String st-new Stringidis.ceadUTEO); System.out.printlost): dis.close(); des cose(); siout.close(); 1.close(); sclose()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
