1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | import java.net.*; import java.io.*; public class server { public static void main(String args[]) throws Exception { ServerSocket ss=new ServerSocket(2000); Socket s=ss.accept(); BufferedReader br=new BufferedReader(newInputStreamReader(s.getInputStream())); double rad,area; String result; rad=Double.parseDouble(br.readLine()); System.out.println("From Client : "+rad); area=Math.PI*rad*rad; result="Area is "+area; PrintStream ps=new PrintStream(s.getOutputStream()); ps.println(result); br.close(); ps.close(); s.close(); ss.close(); } } public class client { public static void main(String args[]) throws Exception { Socket s=new Socket("192.168.0.19",2000); BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String rad; System.out.println("Enter radius of the circle "); rad=br.readLine(); PrintStream ps=new PrintStream(s.getOutputStream()); ps.println(rad); BufferedReader fs=newBufferedReader(new InputStreamReader(s.getInputStream())); String result=fs.readLine(); System.out.println("From Server : "+result); br.close(); fs.close(); ps.close(); s.close(); } } |
Output:
Java client
Enter radius of the circle
10
From Server: Area is 314.1341345
Description :
This is the one stop educational site for all Electronic and Computer students. If you want to learn something new then we are here to help. We work on Microcontroller projects, Basic Electronics, Digital electronics, Computer projects and also in basic c/c++ programs.
#Home #Sitemap #Submit #Terms of Use
Copyright©2011 electrofriends.com All Rights Reserved
Contact:info@electrofriends.com | Powered by Dhyeya
December 12th, 2011 at 12:32 pm
Dear Sir,
We would like to request you that we want a java program on Equation Grapher…. The equation will be like that r(t) = A cos(t)+B sin(t).
Thanking You,