In: Computer Science
###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()