Iterative Online Auction Client-Server model – This chapter deals with the design and development of an iterative online auction server and a client which is ready to participate in the bidding. The auction server maintains 3 products in the database along with the product id, original bid, current bid, bid end time. All the 3 product details are maintained in the product database (file type) The server checks for the client connections and the bidding by the clients and updates the database maintained.
Algorithm for TCP Client and Socket
a) Algorithm for TCP Server
- Obtain the IP address of the server and the corresponding port number
- Create a TCP server socket
- Bind the server socket to server IP address and port number.
- Accept new connection from client and return a client socket that represents the client which is connected.
- Send and receive data with client using the client socket.
- Close the connection with the client.
b) Algorithm for TCP Client
- Find the IP address and port number of the server for establishing connection.
- Create a TCP socket.
- Connect the socket to server (Server should be running and listening to requests).
- Send and receive data with the server using the socket.
- Close the connection.
Algorithm for handling the online auction
a) Online Auction Iterative server
- The server keeps listening to the client connections which would like to participate in the bidding process.
- Once a client requests a connection, the connection is established, and serves the client in the bidding process.
- At this point, it just listens to the other clients willing to bid and places them in a queue but doesn’t establish a connection until the client which is being serviced currently has been processed since this is an iterative server.
- Once the connection is established, the server waits for the client data regarding the bid details. The server waits for 25 seconds before it times out.
- This is because if a client gets connected and does not send any bid details, it is blocked and cannot service any other waiting clients. So if the time is set for the bid data reception, then once the timeout occurs, the server can proceed to process the waiting clients.
- The server processes the bid, and sends the corresponding message to the client.
- If the bid value is more than the current bid value and before the bid time has ended, the value is updated in the server database and a success message is sent to the client.
- If the bid value is lower, then the message is sent to the client to increase the bid value.
- If the bid time has ended, then the server sends the message that the bid time has ended.
- Once the processing of the bid request from a particular client is completed, the client socket is closed and new client is processed which is in the listening queue.
Online Auction Iterative client
- The client first establishes a connection with the server. If the server is already servicing another client, then it waits till there is response from the server.
- Once the client is connected, the user data is sent to the server for processing the bid.
- The server processes the data and sends the success or error message accordingly which the client displays on the terminal.
An iterative online auction client-server model is a system in which multiple clients connect to a central server to participate in an auction. The auction is conducted in an iterative manner, with multiple rounds of bidding until a winner is determined.
Here is a basic outline of how such a system might work:
- The server sets up an auction and specifies the items or services being auctioned, the starting bid, and the rules for bidding (e.g. minimum bid increments, time limits for bidding rounds).
- Clients connect to the server and register to participate in the auction. The server keeps track of the clients’ identities and bids.
- The server starts the first round of bidding, during which clients can submit bids for the auctioned item. Clients can see the current highest bid and must submit a higher bid if they wish to participate. The server may set a time limit for this round of bidding.
- Once the time limit has been reached, the server determines the highest bidder and announces the winner of the round.
- The server then starts the next round of bidding, using the same rules as before but with a new starting bid that reflects the outcome of the previous round.
- This process continues until there is only one bidder left, who is declared the winner of the auction.