0% found this document useful (0 votes)
10 views2 pages

Simple Java Client-Server Example

This document provides code for a simple Java client/server application. The client code prompts the user to enter a radius, sends the radius to the server, and receives the calculated area back. The server code accepts the radius from the client, calculates the area of a circle using that radius, and sends the result back to the client.

Uploaded by

Diksha Kashyap
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

Simple Java Client-Server Example

This document provides code for a simple Java client/server application. The client code prompts the user to enter a radius, sends the radius to the server, and receives the calculated area back. The server code accepts the radius from the client, calculates the area of a circle using that radius, and sends the result back to the client.

Uploaded by

Diksha Kashyap
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

WRITE A JAVA PROGRAM THAT IMPLEMENTS A SIMPLE

CLIENT/SERVER APPLICATION.

import [Link].*;
import [Link].*;
class Client
{
public static void main(String ar[])throws Exception
{
Socket s=new Socket([Link](),10000);
[Link]("enter the radius of the circle ");
DataInputStream dis=new DataInputStream([Link]);
int n=[Link]([Link]());
PrintStream ps=new PrintStream([Link]());
[Link](n);
DataInputStream dis1=new DataInputStream([Link]());
[Link]("area of the circle from server:"+[Link]());
}
}
import [Link].*;
import [Link].*;
class Server
{
public static void main(String ar[])throws Exception
{
ServerSocket ss=new ServerSocket(10000);
Socket s=[Link]();
DataInputStream dis=new DataInputStream([Link]());
int n=[Link]([Link]());
PrintStream ps=new PrintStream([Link]());
[Link](3.14*n*n);
}
}

OUTPUT

enter the radius of circle : 3

area of the circle from the server: 28.86

You might also like