C Programming Language Write the code for a client and a ser

C Programming Language.

Write the code for a client and a server. You will invoke the client 3 separate times. Each client sends the server an integer and its private FIFO name. The server adds the integers that it gets from all three clients and sends the sum back to all 3 clients through their private FIFOs.

Solution

int a,b,sum; try { Socket Server_info = new Socket (\"localhost\", 15000); BufferedReader FromServer = new BufferedReader (new InputStreamReader(Server_info.getInputStream())); DataOutputStream ToServer = new DataOutputStream(Server_info.getOutputStream()); while (true) { System.out.println(\"Type in \'0\' at any point to quit\"); System.out.println(\"Please input a number\"); a = User_in.nextInt(); ToServer.writeInt(a); System.out.println(\"Please input a second number\"); b = User_in.nextInt(); ToServer.writeInt(b); sum = FromServer.read(); System.out.println(\"the sum of \" +a+ \" and \" +b+ \" is: \" +sum ); if (a==0 || b==0) break; }
C Programming Language. Write the code for a client and a server. You will invoke the client 3 separate times. Each client sends the server an integer and its p

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site