Java program For client server communication client program - Code

Latest

programs

Monday, October 10, 2011

Java program For client server communication client program


import java.net.*;
import java.io.*;
public class  client
{
public static void main(String args[]) throws Exception
{
Socket s=new Socket("localhost",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=new 
BufferedReader(new InputStreamReader
(s.getInputStream()));
String result=fs.readLine();
System.out.println("From Server : "+result);
br.close();
fs.close();
ps.close();
s.close();
}
}

No comments:

Post a Comment