Question

In: Computer Science

Client side program: Develop a client side program which will do the following: The client side...

Client side program: Develop a client side program which will do the following:
The client side would accept the customer ID and the amount that customer has spent. The client will then forward the customer ID and the amount spend the server. (Include field validation wherever possible)
a. Request connection to the server
b. Accept and forward the necessary data to the server
c. Receive and display the results from the server
d. Close the connection after use

Solutions

Expert Solution

###Program is written in Python as no language specification is menitoned in the question###
###Client###
import socket
def Main():
host = "128.0.0.1"
port = 6000

mySocket = socket.socket()
print("Requestng connection to the server")
mySocket.connect((host,port))
print("Accepting and forwarding the necessary data to the server")
customerID=(input("Enter customerID")
amount =int(input("Enter amount spent"))
mySocket.sendall(str.encode("\n".join([str(customerID), int(amount)])))
data = mySocket.recv(1024).decode('utf-8')
print ("Receiving and displaying the results from the server: " %data)
print("Closing connection")
mySocket.close()


if __name__ == "__main__":
Main()

###Server###
import socket

def Main():
host = "128.0.0.1"
port = 6000

mySocket = socket.socket()
mySocket.bind((host,port))

mySocket.listen(1)
conn, addr = mySocket.accept()
print ("Client address: " + str(addr))
while True:
cusID, amountspent = [int(i) for i in c.recv(1024).decode('utf-8').split('\n')]
datafromserver=mySocket.sendall(str.encode("\n".join([str(cusID), int(amountspent)])))
conn.send(datafromserver.encode())

conn.close()

if __name__ == "__main__":
Main()


Related Solutions

You will develop a program in C++ that will do a "find and replace" on an...
You will develop a program in C++ that will do a "find and replace" on an input file and write out the updated file with a new name. It will prompt your user for four inputs: The name of the input file. The characters to find in the input file. The replacement (substitute) characters. The name of the output file. It will perform the replacement. Note1: all instances must be replaced not just the first one on a line. Note2:...
You will develop a program in C++ that will do a "find and replace" on an...
You will develop a program in C++ that will do a "find and replace" on an input file and write out the updated file with a new name. It will prompt your user for four inputs: The name of the input file. The characters to find in the input file. The replacement (substitute) characters. The name of the output file. It will perform the replacement. Note1: all instances must be replaced not just the first one on a line. Note2:...
Develop a client /server talk application in C or C++. You should run your server program...
Develop a client /server talk application in C or C++. You should run your server program first, and then open another window if you use loopback to connect the local host again, or you may go to another machine to run the client program that will connect to the server program. In this case you must find the server’s IP address first, and then connect to it. If you use loopback, your procedure may look like: ➢ Server Server is...
Develop an assembly language program for 89c51 to do following {Marks 10} Store any 8 values...
Develop an assembly language program for 89c51 to do following {Marks 10} Store any 8 values of one byte each anywhere in Scratch Pad area of RAM. You are bound to use loop to store values. Find Mean of these 8 values (use shift operator for division) and send it to port P2 (formula for to find mean is given below) Find the lowest number among the numbers saved in part (1), take its 2’s complement and send it to...
How does the addition of computation on the server side and client side alter Sir Tim...
How does the addition of computation on the server side and client side alter Sir Tim Berners Lee’s original computational model?
DEVELOP IN VISUAL STUDIOS C++ PLEASE 1. Develop a main program that does the following a)...
DEVELOP IN VISUAL STUDIOS C++ PLEASE 1. Develop a main program that does the following a) Create six nodes of integers such as n0, n1, n2, n3, n4, n5 (n0 is the head) b) Assign data to each nodes such as n1->data = 2; n2->data = 5, n3->data = 3, n4->data = 10, n5->data = 1. c) Make n0 ->next to point to n1, and n0->prev to point to NULL 2.) Print out the content of list you have created...
Write a C++ program using separate void which asks the user to input side of a...
Write a C++ program using separate void which asks the user to input side of a square, radius of a circle , height and base of a triangle and finds the area of squares, circles and triangles. Then using main function display the area of square, circle and triangle
Which of the following is considered to be an example of a side cost or benefit...
Which of the following is considered to be an example of a side cost or benefit for investment analysis? 1 Project Cannibalization 2 Project Synergies 3 Opportunity Costs 1 only 1 and 2 only 2 and 3 only 1,2 and 3 Which of the following statements is true about side projects? 1 Opportunity costs are not considered relevant for cash flow analysis 2 Product cannibalization occurs when a project compromises the value created by another 3 Project synergies are commonly...
Which side effect should the nurse tell a client to expect before administering anti-angina nitrates? Answers:...
Which side effect should the nurse tell a client to expect before administering anti-angina nitrates? Answers: A Muscle spasms B Wheezes C Chills D Headache
Training Program: Design a full 12-week periodized training program for the client described in the Client...
Training Program: Design a full 12-week periodized training program for the client described in the Client Profile. Be very specific as you design the training program. This is an opportunity for you to demonstrate your full comprehension of the information and concepts discussed throughout the course. List the types of exercise, duration, sets, reps, rest intervals, and so on. Include the following in your case study submission: A description of your professional responsibilities as discussed in the stages of the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT