辅导ICS 53编程、 写作C++语言

” 辅导ICS 53编程、 写作C++语言ICS 53, Winter 2021Assignment 5: Client/Server programmingYou will write a networked client/server application which allows a client program to query aserver program to fetch stock market information. Your programs will allow a user to examinestock prices for two major stocks namely Apple(AAPL) and Twitter(TWTR). The user will entercommands into the client program which runs on one machine. For each command entered bythe user, the client program sends a message containing the query command. The serverprogram receives the query and responds with a message containing the requestedinformation. Below, we will describe the details of query commands and the format of the stockdata.1. Running the Client/ServerThe application is actually two different programs, the client program and the server program.These two programs should both be running as two separate processes which are invoked bythe user in a shell. These two programs may be running on the same machine but they may berunning on two different machines. Since the client and server are communicating using TCP/IP,you will need to select a port to use for communication. ICS Computer Support has advised usthat ports 30000 60000 are all available for your use, so you can use any one of those ports.2. Stock Data FormatYour program will use historical stock prices of AAPL and TWTR as the stock prices used for buyand sell transactions. In addition to downloading this assignment from Canvas, you will need todownload the following two files: AAPL.csv and TWTR.csv. These two files contain stock pricedata for AAPL and TWTR, respectively. When your server program starts executing, historicalprice data will need to be read from these two files before any transactions can be made by theclient.Each file contains stock price information on each trading day between 7/2/2018 and6/30/2020. Each file is in CSV format, which stands for comma-separated value. Thecontents of the file are a table With a series of columns. The first line contains the titles of eachcolumn and every line after the first contains the data on each column. The column data oneach line is separated by a comma. The data that we are interested in on each line is the date(first column) and the closing price (fifth column). Your program will need to read the closingprice on each day and store it so that it can be used as the stock price for buy and selltransactions. You will notice that the files do not include information for all days such asweekends and holidays, so there are gaps in the data.3. Commands SummaryYour program should accept the following commands related to historical price data: Prices: This command should display the stock prices of a stock on a given date. Thiscommand takes 2 arguments, name of the stock and the date. If the date entered by the userdoes not correspond to any entries in the appropriate stock data file, the server will respondwith the string Unknown and this string should be printed on the screen by the client. MaxProfit: This command should calculate the maximum possible profit for a single share of agiven stock. This profit should be considered over the entire time period described by thehistorical data, between 7/2/2018 and 6/30/2020. In other words, if you buy your stock whenthe stock price is minimum and sell it when the stock price is at its max, what will be the profit.Note that the selling date must be later than the buying date. This command takes 1 argument,name of the stock (AAPL or TWTR). quit: This command ends the program4. Starting the ServerIf we assume that the name of the servers compiled executable is server then you wouldstart the server by typing the following at a linux prompt,./server AAPL.csv TWTR.csv 30000(The last argument is the port number that the server will listen to. The previous argumentsindicate the CSV files to be read by the server)The server must first read the contents of the CSV files provided in the command linearguments. When the reading is Finished, it should start listening to the client requests on theport mentioned as the last command line argument and should print server started\n. Itshould wait to receive messages from a client.5. Starting the ClientIf we assume that the name of the clients compiled executable is client then you would startthe client by typing the following at a linux prompt:./client server.ics.uci.edu 30000(The first argument is the domain name of the server and the second argument is the portnumber the server is listening to.)Remember server.ics.uci.edu is just an example of the domain name of the machine that serveris running on. If you run both client and server on the same machine, you can use localhostinstead to loop back the connection between client and server. When the client starts it shouldprint a prompt on the screen and wait for input from the user. (Note: is one and onespace.)6. Message FormatEach message sent between the client and the server must contain two pieces of information, astring, and the length of the string. In messages sent from the client, the string will be the querycommand entered by the user. In messages sent from the server, the string will be therequested stock price (for the Prices command) or the profit value (for the MaxProfitcommand). Each message must be shorter than 256 bytes long and must be formatted asfollows:● Byte 0: Length of the string● Bytes 1 n: Characters of the string7. User interface of the ClientRequests for stock information are made by the user entering the query commands at theclients prompt. When this information is entered at the clients prompt, the client will send arequest message containing the query command to the server, and the client will await aresponse from the server. The server will send a response message containing thecorresponding information.. The client will print the received information to the screen, print aprompt on a new line, and wait for more input from the user. An example of a user interactionwith the client is shown below. It is Derived from the first row of database examples. Prices AAPL 2018-07-02187.18 Prices TWTR 2019-05-0838.58 MaxProfit AAPLMaximum Profit for AAPL: 224.34 quityou are back to the linux prompt.The client will continue in this loop until the user enters quit which will cause the clientsprocess to exit. (Note: No need to print anything after quit was entered.)8. User Interface of the ServerOnce running, the server will only accept requests sent from one client over the network. Whenthe server receives a request from a client, the server will print the requested query commandin the message on the screen on a new line. An example of the printed output of the serverwhen communicating with the client is shown below.server startedPrices AAPL 2018-07-02Prices TWTR 2019-05-08MaxProfit AAPLThe server will continue responding to requests and printing the associated information until itsprocess is killed externally, for instance by a ctrl-c typed at the keyboard.9. Example Execution (both client and server run on circinus-28 in this example)Client$ ./client circinus-28 30010 Prices AAPL 2018-07-02187.18 Prices TWTR 2019-05-0838.58 Prices AMZN 2019-05-08Invalid syntax Prices TWTR 20-05-2019Invalid syntax Prices AAPL 2023-05-05Unknown MaxProfit AAPLMaximum Profit for AAPL: 224.34 quit$Server$ ./server AAPL.csv TWTR.csv 30010server startedPrices AAPL 2018-07-02Prices TWTR 2019-05-08MaxProfit AAPL^C$10. Implementation Details● If the command entered into the client is invalid for any reason, just print Invalidsyntax\n.● The commands and arguments should be case-sensitive.● When the date is Provided as an argument to a command, it should be provided inYYYY-MM-DD format.● When a stock name is provided as an argument, it should be provided as its tickersymbol, AAPL, or TWTR.● If the date value typed into the client is not present in the stocks file which is known tothe server, just print Unknown and continue the program.11. Submission InstructionsYour source code must be two C files (client.c and server.c). Be sure that your program mustcompile on openlab.ics.uci.edu using gcc version 4.8.5. You can check your gcc version with thegcc -v command. Make sure that you do not use C99 features. Make sure both files cancompile with gcc filename.c and do not require any flags or modifications. Submissions willbe done through Gradescope. The first line of your submitted file should be a comment whichincludes the name and ID number of you and your partner (if you are working with a partner).如有需要,请加QQ:99515681 或WX:codehelp

添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导