/*may be u can try this
the server programe belllow*/
import java.net.*;
import java.io.*;
import java.util.*;
import java.lang.Object;
public class Server12
{
public static void main(String args[])
{
try
{
Server12 world=new Server12();
}catch(IOException e){}
}
static final public int PortNumber =8000;
public Server12()throws IOException
{
ServerSocket SS=new ServerSocket(PortNumber);
Socket S=SS.accept();
while(true)
{
System.out.println("\nWaiting....Run the Client Program");
// Socket S=SS.accept();
System.out.println("\nClient found and Message Shown");
//OutputStreamWriter OSW=new OutputStreamWriter(S.getOutputStream());
ObjectInputStream fromclient;
fromclient =new ObjectInputStream(S.getInputStream());
DataOutputStream toclient=new DataOutputStream(S.getOutputStream());
int i=fromclient.readInt();
System.out.println("\nClient send :"+i);
int x=i*i*3;
toclient.writeInt(x);
String Msg="Current Date And Time on Server is:"+new Date()+"\n";
//OSW.write(Msg);
// OSW.close();
}
}}
//the client programe is
import java.net.*;
import java.io.*;
import java.util.*;
public class Client12
{
public static void main(String args[])
{
try
{
Client12 world=new Client12();
}catch(IOException e){}
}
static final public int PortNumber =8000;
public Client12()throws IOException
{
Scanner as=new Scanner(System.in);
Socket S=new Socket("127.0.0.1",PortNumber);
DataInputStream fromserver=new DataInputStream(S.getInputStream());
//BufferedReader BR=new BufferedReader(R);
DataOutputStream toserver=new DataOutputStream(S.getOutputStream());
//int rad=0;
for(
{
System.out.print("enter=");
int rad=as.nextInt();
System.out.print("you have entered=="+rad);
toserver.writeInt(rad);
int r=fromserver.readInt();
System.out.print("you have entered=="+r);
// fromserver.flash();
System.out.println("\nreply From Server:\n"+r);
}
}}
/*
this is to sending a int value from client and the server inresponse gives a calculation that is int x.then the client reads the int receved from server .the receved integer is int r in the client programe and then print it.u then change it as ur needs.*/