辅导案例-CS475
Programming Project III CS475 Randall DUE Oct 16, 2019 For Programming Project III you will be writing a Currency Exchange Rate server/client application. The exchange rate information will come from a third party API https://exchangeratesapi.io/. API Request Examples: https://api.exchangeratesapi.io/latest HTTP/1.1 Example Response {"rates":{"CAD":1.4468,"HKD":8.6261,"ISK":138.7,"PHP":57.354,"DKK":7.4607,"HU F":332.4,"CZK":25.867,"AUD":1.6021,"RON":4.7348,"SEK":10.6563,"IDR":15470.22, "INR":78.872,"BRL":4.4721,"RUB":71.8661,"HRK":7.3945,"JPY":118.51,"THB":33.65 3,"CHF":1.0934,"SGD":1.518,"PLN":4.3335,"BGN":1.9558,"TRY":6.3335,"CNY":7.830 9,"NOK":9.8745,"NZD":1.7147,"ZAR":16.1384,"USD":1.1003,"MXN":21.4565,"ILS":3. 899,"GBP":0.89133,"KRW":1312.34,"MYR":4.5987},"base":"EUR","date":"2019-09- 11"} Your Server Program should allow a client application to make a request to receive currency data from at least 10 different currencies. To start your client application, it should take 2 arguments the server name, and server port number. Your client application should use gethostbyname to resolve the server IP. Your Client application should provide a text based menu that will provide the user a list of currencies. The user should be prompted to select a “to” and “from” list. The user should then be asked to enter an amount of (“from” currency). Once the selection has been made the client should contact your server to retrieve the current exchange rate data for the selected currencies. The Client should then disconnect from the server. The client should then present the exchange rate and the “to” amount for the amount entered above. The data should be displayed clearly for the user. At this point the user should be asked if they would like to check any additional exchange rates loop if needed. Making the html request from c++ is simple. You will be connected to the wunderground server just like you have connected to any other server, but you will connect via port 80. Once you are connected you will perform a Get command on the server which will return the XML code to your program you will need to programmatically retrieve the data and parse out the information that you need. Get: The following 2 lines of code request the data from the weather server once a socket has been created with the server. The first argument “weather” below is the socket descriptor that was created with the server. send(socketDesc, " GET https://api.exchangeratesapi.io/latest HTTP/1.1\r\n\r\n",strlen("GET https://api.exchangeratesapi.io/latest HTTP/1.1\r\n\r\n"), 0); The final portion of project 3 will be to write an application protocol for your application. The Protocol should explain data transfer, and the client/server relationship.