Reference no: EM132112753
Purpose
To practice UDP programming, including the use of the socket, bind, sendto, and recvfrom system calls.
Assignment
Write a C++ program that will validate (imaginary) credit card transaction information by querying to a UDP server. You will be writing the client, and the server's address and port information will be provided to you.
Program
Implement a C++ program that prompts the user for the details of a credit card transaction. These details include the name of the card holder, the credit card number, the expiration date, and the dollar amount to be authorized. The card holder name is a string. The card number must be a 15 or 16 digit number. The expiration date is of the form MM/YYYY (eg. 12/2019). The amount will be a number with two digits after the decimal point.
Your program will send the information to a UDP server in a single datagram containing all of the information spec- ified. The server will respond with a single datagram, containing whether the credit card transaction is valid, and an authorization code.
The UDP datagram sent to the server must contain the card number, expiration date, amount, and card holder name in a colon separated list, for example: "6011 1234 4321 1234:12/2016:543.21:John Doe".
UDP Server Details
The details for the UDP Server will be listed in the assignment listing on BlackBoard.
Error Checking
Your program must check whether the name, credit card, expiration date, and amount are well formed. If they are not, prompt the user for them again.
Name can be any string less than 64 characters. Credit card number must be either 15 or 16 digits, with the possibil- ity that spaces may be used between numbers to separate them into groups. The expiration date must be of the form MM/YYYY (obviously MM should be between 01 and 12). The amount can be any number digits followed by a decimal point and then two more digits.