Question
The exercise is familiarity with the inter-process communication (IPC-Inter-Process Communication) and with sockets Internet. For this purpose, you are invited to implement using system calls
The exercise is familiarity with the inter-process communication (IPC-Inter-Process Communication) and with sockets Internet. For this purpose, you are invited to implement using system calls socket(), bind(), connect(), fork() etc. an "online store" e-shop which accepts orders from customers via "internet". The eshop will have a list of products for which it is limited available number of pieces for each. "Customers" will submit the request to purchase the products online store, and if the products are available, the store will inform him customer for the success of the order, the total charge and will bind them products. Otherwise, it will inform the client that it does not exist product you requested. The online store will have a specific processing time order (even 0.5 seconds). At this time, he will not accept any more orders, until it finishes serving. Each customer will submit a series of orders with a difference e.g. 1 seconds between orders. Once all orders are completed, the online store will issue one consolidated report in which the following will be described for each product information: 1) Product description 1) Number of purchase requests 2) Number of units sold 3) List of users who were not served (i.e. did not find the product available) At the end of the report a summary message will be printed containing: 1) Total number of orders 2) Total number of successful orders 3) Total number of failed orders 4) Total turnover Implementation Guidelines You will implement the catalog through a table (even a catalog) which will exists in the parent process (server). The table will have a size of e.g. 20 different products. Each product will be a structure (struct) that you will implement you and will contain at least the following fields: description, price, item_count. For each product set the item_count value to 2 (ie there are 2 available products with this description). The parent process (parent) will run the eshop task. The paternal process It should initialize the catalog table and initialize a socket for to accept messages from clients via sockets. Through the sockets it will be possible to accept orders from customers (for an order customers will write with write to the socket, and the server will read with read from the socket). To be informed about the progress of the order, the reception will be used that you have already created (this is a two-way communication), in which the server will write (write) and from which the client will read (read) it message that will describe the result of the order (i.e. whether it found or not the requested product). Order processing time will be 1 second. You can implement the processing time using the sleep() system call from the paternal process. Clients will communicate with the eshop through internet sockets, according to what we have said in the laboratory. To check the program, you will create 5 different clients. Each customer will send 10 orders and then it will terminate its execution. Between orders it will wait 1 second. The wait can be implemented using the system call sleep(). For each order, it will run the rand() function to pick one random number between 0 and 20 (where 20 is the different products). As soon as he chooses the product, will put (write) its order in the slot and wait for it result of his order. For clients it is necessary to use fork().
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started