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

Give your opinion on server-side vs. client-side validation. Which is better in your opinion? Who should...
Give your opinion on server-side vs. client-side validation. Which is better in your opinion? Who should have the power in this validation process
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 program, in which you'll design a class that holds the following personal data: name,...
Develop a program, in which you'll design a class that holds the following personal data: name, address, age, and phone number. As part of the program, you'll then create appropriate accessor and mutator methods. Also, set up three instances of the class. One instance should hold your information, and the other two should hold your friends’ or family members’ information. Input: data for the following attributes of 3 instances of the  Personal Information Class: name, address, age, and phone number NOTE:...
Write a program in Python language which will do the following: Write a program to prompt...
Write a program in Python language which will do the following: Write a program to prompt the user to enter a company name, city, state and zip code. Create a dictionary with the data. Output the dictionary. Then remove the city from the dictionary and output again.
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?
In each of the following situations, develop a tentative plan for the client. List the various...
In each of the following situations, develop a tentative plan for the client. List the various services you believe each person needs initially. Include in your plan for each client both formal and generic services, and where appropriate, use social supports and support groups. Suggest other services the person might use later once the case is stabilized. Think about how you can involve others close to the per- son and how you will involve the client in planning. You are...
Problem 2: Do a side-by-side comparison of Cascading and the following technologies in regards to writing...
Problem 2: Do a side-by-side comparison of Cascading and the following technologies in regards to writing Hadoop applications. Make sure you include the advantages and disadvantages of each, as well as when to use each technology over the other. Cascading vs. cascalog
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT