Question

Please use Python programming language to write a client program and a server program, so that...

Please use Python programming language to write a client program and a server program, so that these two programs communicate through a TCP connection based on the following scenario:

  1. Both of the client program and the server program are running on the same localhost.
  2. The client program prompts the user to enter the radius of a circle and pass it to the server program.
  3. The server program computes the area of this circle and passes it to the client program.
  4. The client program displays the area on the screen

Homework Answers

Answer #1

CLIENT.py

from socket import *
s=socket(AF_INET, SOCK_STREAM)
s.connect(("localhost",8000))
r=s.recv(1024)
a=input(r)
s.send(bytes(str(a), 'utf8'))
area=s.recv(1024)
AREA=area.decode('utf8')
print("Area of Circle is:",AREA)

---------------------------------------------------------------------------------------

SERVER.py

from socket import *
s=socket(AF_INET, SOCK_STREAM)
s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
s.bind(("", 8000))
s.listen(5)
c, a=s.accept()
c.send(bytes("Enter Radius",'utf8'))
m=c.recv(1024)
R=m.decode('utf8')
radi=int(R)
area=radi*radi*3.14
c.send(bytes(str(area),'utf8'))

Instructions-

1-First run the server.py (I did using command prompt).

2-Then run client.py. (usiing command prompt)

3-Screenshot is shared of rummimg code.

4-If getting an error because of ports than change ports.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
(Python Programming) Write a program that prompts a user for a positive integer and then uses...
(Python Programming) Write a program that prompts a user for a positive integer and then uses a loop to calculate and display the sum of specific fractions as follows: Let's say the user enters 5, then your program will compute: 1/5 + 2/4 + 3/3 + 4/2 + 5/1 which is 8.7.
1. Please use only the C as the language of programming. 2. Please submit/upload on Canvas,...
1. Please use only the C as the language of programming. 2. Please submit/upload on Canvas, the following les for each of your programs: (1) the client and the server source les each (2) the client and the serve executable les each (3) a brief Readme le that shows the usage of the program. 3. Please appropriately comment your program and name all the identiers suitable, to enable enhanced readability of the code. Problems 1. Write an ftp client that...
Write a Python program to calculate the area of a circle. The user needs to input...
Write a Python program to calculate the area of a circle. The user needs to input the value of the radius of the circle. area = 3.14 x radius x radius You should use a function named circlearea to perform the calculation 3. Write a Python program to calculate the area of a square. The user needs to input the value of the length of the square. area = len*len You should use a function named squarearea to perform the...
The goal of this assignment is to implement a simple client-server system. You have to use...
The goal of this assignment is to implement a simple client-server system. You have to use Python. The basic functionality of the system is a remote calculator. You first will be sending expressions through the client to the server. The server will then calculate the result of the expression and send it back to the client where it is displayed. The server should also send back to the client the string "Socket Programming" as many times as the absolute value...
In C programming, Thank you Write a program to compute the area of a circle. You...
In C programming, Thank you Write a program to compute the area of a circle. You have to write a complete “C” program that compiles and runs in Codeblocks. Program requirements: 1. Declare the variables needed: radius (r) and area (yourLastName). 2. Calculate and print the area of each circle. 3. The program MUST prompt the user for a new radius (r) over and over until the user types -1. 5. Use the type double for all decimal numbers. 6....
Please write the code in Python. Write a program/function in any Object-Oriented programming language that will...
Please write the code in Python. Write a program/function in any Object-Oriented programming language that will implement Queue Abstract Data Type with the following functions/methods.  Any build-in/pre-defined Queue function/library (e.g., java.util.Queue in Java) is NOT allowed to use in your code. push(Element):  insert the input Element (e.g., String or Integer in Java) to the end of the queue. pop(): remove the head element of the queue and print the head element on screen. count():  return the total number of elements in the queue...
PLEASE USE JAVA Write a program that draws the circumscribed circle (also known as the circumcircle)...
PLEASE USE JAVA Write a program that draws the circumscribed circle (also known as the circumcircle) of a given triangle ABC; this circle passes through points A, B, and C. These points will be specified by the user by clicking the mouse button. Remember, the three perpendicular bisectors of the three edges of a triangle all pass through one point, the circumcenter, which is the center of the circumscribed circle.
Client / Server using named pipes with thread and fork() in C/C++ **Note** You will need...
Client / Server using named pipes with thread and fork() in C/C++ **Note** You will need to write a client program and a server program for this question to be correct. ** **Cannot use socket** client the client application that will get the command from the user and pass the command to be executed from the command line, parses the command and puts a binary representation of the parse into a shared memory segment. At this point, the client will...
Write a Python program that reads in the month, day, and year of a date and...
Write a Python program that reads in the month, day, and year of a date and prints it in the dd/mm/yyyy format or mm/dd/yyyy format, the format depending on the user’s preference. The program also prints the message It is a magic date If the product of month and day is equal to the last two digits of the year. For example, April 20 1980 is a magic date because April (numeric value 4) multiplied by 20 is equal to...
Please I need this to be done in PERL language only Write a program that prompts...
Please I need this to be done in PERL language only Write a program that prompts the user for a filename, then reads that file in and displays the contents backwards, line by line, and character-by character on each line. You can do this with scalars, but an array is much easier to work with. If the original file is: abcdef ghijkl the output will be: lkjihg fedcba AND Modify the previous script to use a die message if the...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT