1. Homepage
  2. Programming
  3. CSSE2310/CSSE7231 Computer Systems Principles and Programming Assignment 4: Real-time, online auction platform

CSSE2310/CSSE7231 Computer Systems Principles and Programming Assignment 4: Real-time, online auction platform

Engage in a Conversation
The University of QueenslandCSSE2310CSSE7231Computer Systems Principles and ProgrammingCReal-time online auction platform

CSSE2310/CSSE7231 — Semester 2, 2023 Assignment 4 (version 1.0)
CourseNana.COM

Introduction The goal of this assignment is to further develop your C programming skills, and to demonstrate your un- 2
CourseNana.COM

derstanding of networking and multithreaded programming. You are to create two programs which together implement a real-time, online auction platform. The main program – auctioneer – is a network server which accepts connections from clients (including auctionclient which you will implement). Clients connect, and interact with auctioneer in various ways to sell and buy items.2263 6 CourseNana.COM

Communication between the clients and auctioneer is over TCP using a newline-terminated text command protocol. Advanced functionality such as connection limiting, signal handling and statistics reporting are also required for full marks. CSSE7231 students shall also implement a simple HTTP interface to auctioneer9 CourseNana.COM

The assignment will also test your ability to code to a particular programming style guide and to use a 10 revision control system appropriately. 11 CourseNana.COM

Student Conduct 12 13 CourseNana.COM

This is an individual assignment. You should feel free to discuss general aspects of C programming and 14 the assignment specification with fellow students, including on the discussion forum. In general, questions like 15 “How should the program behave if this happens?” would be safe, if they are seeking clarification on the 16 specification. 17 CourseNana.COM

You must not actively help (or seek help from) other students or other people with the actual design, structure 18 and/or coding of your assignment solution. It is cheating to look at another student’s assignment code 19 and it is cheating to allow your code to be seen or shared in printed or electronic form by others20 All submitted code will be subject to automated checks for plagiarism and collusion. If we detect plagiarism or 21 collusion, formal misconduct actions will be initiated against you, and those you cheated with. That’s right, if 22 you share your code with a friend, even inadvertently, then both of you are in trouble. Do not post your 23 code to a public place such as the course discussion forum or a public code repository. (Code in private posts 24 to the discussion forum is permitted.) You must assume that some students in the course may have very long 25 extensions so do not post your code to any public repository until at least three months after the result release 26 date for the course (or check with the course coordinator if you wish to post it sooner). Do not allow others to 27 access your computer – you must keep your code secure. Never leave your work unattended. 28 CourseNana.COM

Code Origin
CourseNana.COM

Code examples found in man pages on moss. CourseNana.COM

Online auctions 53
CourseNana.COM

In a simple auction, an item is put up for sale by a seller. One or more buyers then place bids – statements 54 describing how much they are willing to pay for the item. Each bid must be higher than the previous. Buyers 55 may place multiple bids, so long as each is higher than the current maximum bid. Once a buyer has set the 56 highest bid, they may not bid again until a different buyer places a higher bid on the item. At the end of the 57 auction, the highest bidder is the winner. 58 CourseNana.COM

The seller sets a reserve price – the lowest amount they are willing to sell the item for. If the auction does 59 not reach the reserve price, the auction ends with the item unsold. The item is described as being passed in60 and there is no winner. Any bids below the reserve price are rejected.2263 61 CourseNana.COM

The auctioneer manages the auction. They receive items and their reserve prices from sellers, and accept 62 bids from potential buyers. The auctioneer is responsible for rejecting invalid bids – such as ones that do not 63 exceed the current maximum bid, and those that are below the reserve. 64 CourseNana.COM

Online auctions face some challenges – automated buying agents can attempt to wait until the very last 65 moments of an auction, and place a bid that is fractionally above the current highest bid, seeking to win the 66 auction for the lowest possible price. This strategy is known as sniping. Because sniping can give an unfair 67 advantage over regular, human-placed bids, it is common to place limits on how frequently bids may be made. 68 CourseNana.COM

In this assignment, all auctions are time-limited, with the duration being specified by the seller when placing 69 the item up for auction. The auctioneer is the final arbiter of time. Bids received after an auction has finished, 70 even if they were sent before expiration, are rejected.2263 71 CourseNana.COM

Specification – auctionclient 72 CourseNana.COM

The auctionclient program provides a command line interface that allows you to interact with the server 73 (auctioneer) as a client – connecting, placing items for sale, finding items available, bidding on other auctions 74 currently underway, and receiving and displaying the results of the auctions on your items. 75 CourseNana.COM

To implement this functionality, auctionclient will probably require two threads – one for handling stdin 76 and sending commands to the server, and another for handling messages from the server. You may optionally 77 use a single thread and multiplexed I/O, such as poll() or select(), however this is not required78 CourseNana.COM

If the correct number of arguments is provided, then further errors are checked for in the order below. 87 Connection error 88 CourseNana.COM

If auctionclient is unable to connect to the auction server on the specified port (or service name) of localhost89 it shall emit the following message (terminated by a newline) to stderr and exit with status 20: 90 CourseNana.COM

auctionclient: connection failed to port N
where should be replaced by the argument given on the command line. (This may be a non-numerical string.) 91 CourseNana.COM

auctionclient runtime behaviour 92 Assuming that the commandline arguments are without errors, auctionclient is to perform the following 93 CourseNana.COM

actions: 94 • connect to the server on the specified port number (or service name) – see above for how to handle a 95 CourseNana.COM

connection error; CourseNana.COM

  • read commandsIf the network connection to the server is closed (e.g. auctionclient detects EOF on the socket), then auctionclient shall emit the following message to stderr and terminate with exit status 5: CourseNana.COM

auctionclient: server has gone away

auctionclient shall interpret its input from stdin as follows: 99 CourseNana.COM

  • Blank lines (i.e. those lines containing no characters), and those beginning with the character (comment 100 CourseNana.COM

    lines), shall be ignored. (“beginning with” means the character is in the leftmost position on the line.) 101 CourseNana.COM

  • The command quit on a line by itself shall cause the auctionclient to exit (with exit status 0) if the 102 client is not currently involved in any auctions, i.e., any auctions for which that client submitted an 103 item for sale are completed, and that client is not currently the highest bidder on any auctions. If those 104 conditions are not true, then the client must print (and flush) the following message to stdout105 CourseNana.COM

         Auction in progress - can not exit yet
    

    and must not exit. 106 CourseNana.COM

  • All other lines shall be sent unaltered to the server (no error checking is required or to be performed) 107 CourseNana.COM

    If auctionclient detects EOF on stdin then it will exit. If the client still has auctions in progress (i.e. it 108 has offered one or more items for sale and those auctions haven’t expired, or if it is currently the highest bidder 109 on one or more auctions) then auctionclient must print the following to stderr and exit with exit status 4: 110 CourseNana.COM

    Quitting with auction(s) still in progress
    

    Otherwise (i.e. the client is not involved in any current auctions), it will print nothing and exit with exit 111 status 0. 112 Upon sending a command to the server, auctionclient shall expect a single line reply as per the commu- 113 nication protocol described in Communication protocol. 114 Other than SIGPIPE ( which is required to gracefully handle the unexpected disconnection by the server) 115 your auctionclient program is not to register any signal handlers nor attempt to mask or block any signals. 116 CourseNana.COM

    auctionclient termination 117 CourseNana.COM

    The recommended architecture for the auctionclient is to have one thread handling stdin and sending 118 commands to the server, and another thread for receiving and interpreting responses from the server. Since 119 blocking reads will be performed on stdin and the server socket, it is difficult to use the methods described in 120 lectures for cleaning up threads (e.g. a “terminate“ flag variable in a shared data structure). For this reason, 121 when either thread detects a valid termination condition for the program, it may simply call 122 exit() immediately – you should not attempt to use pthread_cancel() or any other, more complicated 123 termination mechanism.2263 124 CourseNana.COM

    The command protocol (see Communication protocol) is designed such that auctionclient can easily keep 125 track of how many auctions it is currently involved in – both as a seller and/or a buyer. All commands sent 126 to auctioneer, whether correct or not, generate replies. By interpreting these replies, auctionclient can 127 determine when all of its auctions have completed. For the purposes of determining this condition, the client 128 may assume that the server is correct and well-behaved. 129 CourseNana.COM

./auctionclient 49152 CourseNana.COM

# A comment line - ignored
# A blank line - ignored

# An invalid item listing, missing an argument sell chicken 10
:invalid CourseNana.COM

1 2 3 4 5 6 7 CourseNana.COM

Version 1.0 CourseNana.COM

# A simple item listing, reserve 10, 30 second auction sell chicken 10 30
:listed chicken
# A duplicate item listing CourseNana.COM

sell chicken 20 60

:rejected CourseNana.COM

# Attempt to bid on own item bid chicken 1000
:rejected
# Another item for sale CourseNana.COM

sell potato 10 30
:listed potato

# Invalid listing - non-numeric reserve price
sell apple zz 60
:invalid
(...time passes, chicken auction over but no bids over reserve ...) :unsold chicken CourseNana.COM

# Fast auction on a cow (5 seconds)
sell cow 1000 5

:listed cow CourseNana.COM

# See all items available (note our items are listed but so too is pumpkin
# listed by a different client before ours. We can see current bids on our items as well) list
:list pumpkin 10 100 76|potato 10 20 7|cow 1000 2000 2| CourseNana.COM

# Bid on the pumpkin, which is accepted
bid pumpkin 110
:bid pumpkin
(...time passes, somebody else outbids us on pumpkin ...) :outbid pumpkin CourseNana.COM

(...time passes, fast cow auction finishes ...)
:sold cow 2500

# try to quit, but potato still unsold
quit
Auction in progress - can not exit yet
(...time passes ...potato has now sold - we have no more ‘live’ auctions) :sold potato 20 CourseNana.COM

# now the quit command can succeed
quit

8 CourseNana.COM

 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

Note that not all possible error conditions are present in this example. 135 CourseNana.COM

Further note that the auctionclient must keep track of items it has listed as they are sold or 136 passed-in – this is the only way it can determine whether it can exit or not. Similarly, it must 137 also keep track of items for which it is the highest bidder. 138 CourseNana.COM

Specification – auctioneer 139 CourseNana.COM

auctioneer is a networked, multithreaded auction server allowing clients to connect, submit items for sale, bid 140 on items, and list the items currently available. All communication between clients and the server is over TCP 141 using a simple command protocol that is described in the Communication protocol section.2263 142 CourseNana.COM

The num-connections argument, if specified, indicates the maximum number of simultaneous client con- 148 nections to be permitted. If this is zero or absent, then there is no limit to how many clients may connect (other 149 than operating system limits which we will not test). 150 CourseNana.COM

The portnum argument, if specified, indicates which localhost port auctioneer is to listen on. If the port 151 number is absent or zero, then auctioneer is to use an ephemeral port.2263 152 Important: Even if you do not implement the connection limiting functionality, your program must correctly 153 handle command lines which include either of those arguments (after which it can ignore any provided values 154 – you will simply not receive any marks for that feature). 155 CourseNana.COM

Program Operation 156 The auctioneer program is to operate as follows: 157 CourseNana.COM

  • If the program receives an invalid command line then it must print the message: 158 CourseNana.COM

         Usage: auctioneer [--maxconn num-connections] [--port portnum]
    

    to stderr, and exit with an exit status of 19. 159 Invalid command lines include (but may not be limited to) any of the following: 160 CourseNana.COM

    • –  either of --maxconn or --port does not have an associated value argument 161 CourseNana.COM

    • –  the num-connections argument (if present) is not a non-negative integer 162 CourseNana.COM

    • –  the port number (portnum ) argument (if present) is not an integer value, or is an integer value and 163 is not either zero, or in the range of 1024 to 65535 inclusive 164 CourseNana.COM

    • –  any of the arguments is specified more than once 165 CourseNana.COM

    • –  any additional arguments are supplied 166 CourseNana.COM

  • If portnum is missing or zero, then auctioneer shall attempt to open an ephemeral localhost port for 167 listening. Otherwise, it shall attempt to open the specified port number. If auctioneer is unable to listen 168 on either the ephemeral or specified port, it shall emit the following message to stderr and terminate 169 with exit status 4: 170 CourseNana.COM

         auctioneer: unable to open socket for listening
    
  • Once the port is opened for listening, auctioneer shall print to stderr the port number followed by a 171 single newline character and then flush the output. In the case of ephemeral ports, the actual port 172 number obtained shall be printed, not zero.2263 173 CourseNana.COM

  • Upon receiving an incoming client connection on the port, auctioneer shall spawn a new thread to handle 174 that client (see below for client thread handling). 175 CourseNana.COM

  • If specified (and implemented), auctioneer must keep track of how many active client connections exist, 176 and must not let that number exceed the connections parameter. See below on client handling threads 177 for more details on how this limit is to be implemented. 178 CourseNana.COM

  • Note that all error messages above must be terminated by a single newline character. 179 CourseNana.COM

  • The auctioneer program should not terminate under normal circumstances, nor should it block or oth- 180 CourseNana.COM

    erwise attempt to handle SIGINT181 CourseNana.COM

  • Note that your auctioneer must be able to deal with any clients using the correct communication protocol, 182 CourseNana.COM

    not just the client programs specified for the assignment. Testing with netcat is highly recommended. 183 Client handling threads 184 CourseNana.COM

    A client handler thread is spawned for each incoming connection. This client thread must then wait for commands 185 from the client, one per line, over the socket. The exact format of the requests is described in the Communication 186 protocol section below. 187 CourseNana.COM

Auction running algorithm 193 The auction is run according to the following algorithm. Refer to the Communication protocol section for details 194 CourseNana.COM

of message syntax and required responses. 195 CourseNana.COM

  • auctioneer receives new items to auction via the sell command. The arguments to this command are 196 validated and if correct, the item is now available for sale. If the command is invalid, the client is informed 197 and the sell command does not succeed.2263 198 CourseNana.COM

  • auctioneer receives bids on sale items via the bid command. If the command syntax is valid, the item 199 exists and is currently available, and the bid on the item is higher than any previous bid on the same 200 item, then the bidding client is remembered as the current winning bidder for that item. If there was a 201 previous winning bidder, that client is sent an outbid message informing it that it has been outbid on the 202 item. If an invalid bid command is received, then the bidding client is informed and the bid is otherwise 203 ignored by auctioneer204 CourseNana.COM

  • auctioneer accepts the list command from any connected client, regardless of whether that client has 205 listed or bid on any items. The list command returns a formatted list describing each item available, its 206 reserve price, current maximum bid, and the time remaining in the auction for that item207 CourseNana.COM

  • When the auction on any item completes (reaches the expiry time), auctioneer takes one of the two 208 following actions: 209 CourseNana.COM

    • –  If there is a winning bid which is greater than or equal to the reserve price, then the winning bidder is 210 sent a win message identifying the item and the winning bid amount. The seller of the item receives 211 sold message indicating the item that was sold and the winning bid amount. 212 CourseNana.COM

    • –  If there were no bids on the item, or no bids at or above the reserve price, then auctioneer sends 213 unsold message to the seller, informing it that the item did not sell. No message is sent to any 214 previous bidding client in the event that the item goes unsold. 215 CourseNana.COM

  • Advanced: auctioneer is to limit bids from clients to a maximum of one bid per item per second. That 216 is, if a client has an accepted bid on an item more recently than one second ago, a rejected message is 217 sent in reply. 218 CourseNana.COM

    About time 219 CourseNana.COM

    auctioneer relies on time to determine when auctions expire. Expiry time is at the resolution of milliseconds220 The following approach to handling time and auction expiry is recommended. You may choose another approach 221 if you wish as long as the behaviour is the same. 222 CourseNana.COM

  • the provided library function “double get_time_ms(void)” returns a floating point time value in seconds, 223 to millisecond resolution, e.g. the value 16.745 represents 16.745 seconds. 224 CourseNana.COM

  • for each auction item, store an expiry time (not a duration). So, as each new item is listed, store its expiry 225 time calculated by (get_time_ms() + duration)226 CourseNana.COM

  • to report auction time remaining (e.g. for the list command), calculate (item.expiry - get_time_- 227 ms())) which will yield a floating point value, in seconds, until the auction expires. Note that the list 228 command shall report time remaining rounded down to the nearest second – see the Communication 229 protocol section for details. 230 CourseNana.COM

    The simplest way to check on expiring auctions is to run a dedicated server thread which periodically checks 231 the current time (get_time_ms()) against each item’s expiry time, and marks as ‘complete’ any such items 232 which have expired, and handle any necessary communication and cleanup associated with expired auctions. 233 Be mindful of locking and mutual exclusion, because client threads may also be accessing the auction data 234 structures while this is taking place. 235 CourseNana.COM

Disconnecting clients 240 CourseNana.COM

If a client disconnects before the end of an auction, (e.g. a read() or equivalent) from the client returns EOF241 or a write() or equivalent fails), the auctioneer is to simply ignore that fact for the purposes of the auction, 242 and close the network connection to that client, cleaning up data structures as required. 243 CourseNana.COM

If a client disconnects, any auctions it was involved with proceeds until they naturally expires244 So, if a disconnected client was selling an item, other clients may still bid on the item in the normal manner. 245 When the auction expires, auctioneer will inform the winning bidder, but will not attempt to send the sold 246 message to the now-disconnected seller. 247 CourseNana.COM

Similarly if a bidder disconnects mid-auction, the auction proceeds and their bid remains valid. 248 If this disconnected client ends up winning the auction, the selling client still receives the sold message, there 249 is just no attempt to communicate to the now-disconnected bidder. If a disconnected client gets outbid, the 250 outbid message is not sent. 251 CourseNana.COM

SIGHUP handling (Advanced) 252 Upon receiving SIGHUPauctioneer is to emit (and flush) to stderr statistics reflecting the program’s operation 253 CourseNana.COM

to-date, specifically 254 • Total number of clients connected (at this instant) 255 • The total number of clients that have connected and disconnected since program start 256 • The number of active auctions in progress (at this instant) 257 • The total number of sell requests received (since program start), including invalid2. and rejected requests 258 • The total number of accepted sell requests received (since program start) 259 • The total number of bid requests received (since program start), including invalidand rejected bids 260 • The total number of accepted bid requests received (since program start) 261 CourseNana.COM

The required format is illustrated below. Each of the seven lines is terminated by a single newline. You can 262 assume that all numbers will fit in a 32-bit unsigned integer, i.e. you do not have to consider numbers larger 263 than 4,294,967,295.2263 264 CourseNana.COM

Listing 1: auctioneer SIGHUP stderr output sample CourseNana.COM

Connected clients: 4
Completed clients: 20
Active auctions: 2
Total sell requests: 20
Successful sell requests: 14
Total bid requests: 34
Successful bid requests: 31

1 2 3 4 5 6 7 CourseNana.COM

Note that to accurately gather these statistics and avoid race conditions, you will need some sort of mutual 265 exclusion protecting the variables holding these statistics. 266 Global variables are NOT to be used to implement signal handling. See the Hints section below for how you 267 can implement this. 268 CourseNana.COM

Client connection limiting (Advanced) 269 CourseNana.COM

If the --maxconn num-connections feature is implemented and a non-zero command line argument is provided, 270 then auctioneer must not permit more than that number of simultaneous client connections to the server. 271 auctioneer shall maintain a connected client count, and if a client beyond that limit attempts to connect, it 272 shall block, indefinitely if required, until another client leaves and this new client’s connection request can be 273 accept()ed. Clients in this waiting state are not to be counted in statistics reporting – they are only counted 274 once they have properly connected.2263 275 CourseNana.COM

HTTP connection handling (CSSE7231 students only) 276 CourseNana.COM

CSSE7231 students shall, in addition, implement a simple HTTP server in their auctioneer implementa- 277 tion. Upon startup, auctioneer shall check the value of the environment variable A4_HTTP_PORT. If set, then 278 auctioneer shall also listen for connections on that port number (or service name). 279 CourseNana.COM

If auctioneer is unable to listen on that port or service name then it shall emit the following message to 280 stderr and terminate with exit status 8: 281 CourseNana.COM

auctioneer: unable to open HTTP socket for listening

The ability to listen on this port is checked after the ability to listen on the “main” port (i.e. the one given 282 on the command line). If the A4_HTTP_PORT environment variable is not set then auctioneer shall not listen 283 on any additional ports and shall not handle these HTTP connections. 284 CourseNana.COM

The communication protocol uses HTTP. The connecting program (e.g. netcat, or a web browser) shall 285 send HTTP requests and auctioneer shall send HTTP responses as described below. The connection between 286 client and server is kept alive between requests. Multiple HTTP clients may be connected simultaneously. 287 CourseNana.COM

Additional HTTP header lines beyond those specified may be present in requests or responses and must be 288 ignored by the respective server/client. Note that interaction between a client on the HTTP port and auctioneer 289 is synchronous – any one client can only have a single request underway at any one time. This greatly simplifies 290 the implementation of the auctioneer HTTP connection handling threads.2263 291 CourseNana.COM

The only supported request method is a GET request in the following format: 292 CourseNana.COM

• Request: GET /stats HTTP/1.1 293 CourseNana.COM

– Description: the client is requesting statistics from auctioneer 294 – Request 295 ∗ Request Headers: none expected, any headers present will be ignored by auctioneer296 ∗ Request Body: none, any request body will be ignored 297 – Response 298 CourseNana.COM

  • ∗  Response Status: 200 (OK). 299 CourseNana.COM

  • ∗  Response Headers: the Content-Length header with correct value is required (number of bytes 300 in the response body), other headers are optional. 301 CourseNana.COM

  • ∗  Response Body: the ASCII text containing the same auctioneer statistics information described 302 in the SIGHUP handling section above. 303 CourseNana.COM

    If auctioneer receives an invalid HTTP request then it should close the connection to that requestor (and 304 terminate the thread associated with that connection). Similarly, if a HTTP client disconnects, auctioneer 305 should handle this gracefully and terminate the thread associated with the connection. HTTP clients are NOT 306 included in the client count statistics. 307 CourseNana.COM

    Program output 308 Other than error messages, the listening port number, and SIGHUP-initiated statistics output, auctioneer is 309 CourseNana.COM

    not to emit any output to stdout or stderr310 Communication protocol 311 CourseNana.COM

    The communication protocol between clients and auctioneer uses simple newline-terminated text message 312 strings as described below. Note that the angle brackets <foo> are used to represent placeholders, and are not 313 part of the command syntax.2263 314 CourseNana.COM

    Supported messages from a client to auctioneer are: 315 CourseNana.COM

  • sell <item> <reserve> <duration> – the client is requesting to sell the item called <item>, with a 316 reserve price of <reserve>, with the auction lasting for <duration> seconds. 317 See below for the conditions that must be met for a sell command to be accepted. 318 CourseNana.COM

  • bid <item> <amount> – the client is requesting to bid <amount> on the specified <item>319 See below for the conditions that must be met for a bid command to be accepted. 320 CourseNana.COM

Single spaces are used as separators between fields, which implies that <item> must not contain spaces. 322 All numerical values must be valid decimal integers (and subject to additional value requirements as described 323 below). 324 CourseNana.COM

Supported messages from auctioneer to a client are as follows. Error conditions in messages should be 325 tested in this order as well – first look for “invalid” commands, then check to see if the command should be 326 “rejected”: 327 CourseNana.COM

  • :invalid – sent by the server to a client if any of the following conditions are true: 328 CourseNana.COM

    – Invalid command word – an empty string or a command word which is not sellbid or list 329 – Too few or too many arguments 330 – An invalid value for a numerical field, including 331 CourseNana.COM

    ∗ not a properly formed integer (e.g. “10.2”, “12p” etc) 332 ∗ a negative reserve price in a sell command 333 ∗ a duration of less than 1 second in a sell command 334 ∗ a bid value of less than 1 in a bid command 335 CourseNana.COM

    – Any other kind of malformed message 2263 336 CourseNana.COM

  • :rejected – sent by the server to a client if one any of the following conditions is true: 337 CourseNana.COM

    • –  a client attempts to bid on an item which is not for sale 338 CourseNana.COM

    • –  a client attempts to bid on an item for which they are already the highest bidder 339 CourseNana.COM

    • –  the client sends a bid command but the bid amount is less than the reserve price or less than or 340 CourseNana.COM

equal to the current maximum bid CourseNana.COM

  • –  a client attempts to bid on an item that they themselves have listed for sale CourseNana.COM

  • –  the client sent a sell command but there is already an item for sale by the same name CourseNana.COM

  • :listed <item> – sent to the client when <item> is successfully listed for auction CourseNana.COM

  • :bid <item> - sent to the client when a bid is successfully placed on <item> CourseNana.COM

  • response to a list command, in the following format: CourseNana.COM

347 <remainN>| 348 349 That is, for each item currently available for auction, the name, reserve price, maximum bid so far, 350 and remaining time (rounded down to the nearest second) is emitted in a space-separated format, fol- 351 lowed by a vertical bar “|” character. Items should be reported in the same order that they were 352 submitted to auctioneer – there is no need to perform additional sorting on the list, simply 353 storing them in order of arrival is sufficient. 354 355 If there are no items currently available for auction, then the string “:list” is returned. 356 CourseNana.COM

<maxBidN> CourseNana.COM

Provided Libraries 364 libcsse2310a4 365 CourseNana.COM

split_by_char() function is available to break a line up into multiple parts, e.g. based on spaces. This is 366 similar to the split_line() function from libcsse2310a3 though allows a maximum number of fields to be 367 specified. 368 CourseNana.COM

The get_time_ms() function will return a millisecond-precision, monotonically increasing time value to 369 support all time-related functions in this assignment. The specific value returned is not particularly meaningful, 370 however the difference between values returned from calls to this function can be used to accurately measure 371 the passage of time. 372 CourseNana.COM

Several additional library functions have been provided to aid CSSE7231 students in parsing/construction 373 of HTTP requests/responses. The functions in this library are: 374 CourseNana.COM

double get_time_ms(void); CourseNana.COM

char** split_by_char(char* str, char split, unsigned int maxFields); int get_HTTP_request(FILE *f, char **method, char **address, CourseNana.COM

HttpHeader ***headers, char **body);
char* construct_HTTP_response(int status, char* statusExplanation, CourseNana.COM

HttpHeader** headers, char* body);
int get_HTTP_response(FILE *f, int* httpStatus, char** statusExplain, CourseNana.COM

HttpHeader*** headers, char** body); void free_header(HttpHeader* header); CourseNana.COM

void free_array_of_headers(HttpHeader** headers); CourseNana.COM

These functions and the HttpHeader type are declared in /local/courses/csse2310/include/csse2310a4.h 375 on moss and their behaviour is described in man pages on moss – see get_time_ms(3)split_by_char(3)376 get_HTTP_request(3), and free_header(3)377lectures. You can also use the provided demo programs demo-auctionclient and demo-auctioneer394 CourseNana.COM

The read_line() function from libcsse2310a3 may be useful in both auctionclient and auctioneer395 CourseNana.COM

  1. The multithreaded network server example from the lectures can form the basis of auctioneer396 CourseNana.COM

  2. Use the provided library functions (see above).2263 397 CourseNana.COM

  3. Consider a dedicated signal handling thread for SIGHUPpthread_sigmask() can be used to mask signal 398 delivery to threads, and sigwait() can be used in a thread to block until a signal is received. You will 399 need to do some research and experimentation to get this working. Be sure to properly reference any code 400 samples or inspiration you use. 401 CourseNana.COM

Possible Approach 402 CourseNana.COM

  1. Try implementing auctionclient first. (The programs are independent so this is not a requirement, but 403 when you test it with demo-auctioneer it may give you a better understanding of how auctioneer 404 works.) 405 CourseNana.COM

  2. For auctioneer, start with the multithreaded network server example from the lectures, gradually adding 406 functionality for supported message types.2263 407 CourseNana.COM

  3. Design a simple data structure for auctioneer to store items for sale. This data structure will be accessed 408 by client threads to add new items, determine validity of bids, and respond to list commands. It will 409 also need to be accessed by whichever thread checks for auction expiry. Locking and mutual exclusion will 410 be essential, but don’t over-complicate it! 411 CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
The University of Queensland代写,CSSE2310代写,CSSE7231代写,Computer Systems Principles and Programming代写,C代写,Real-time代写, online auction platform代写,The University of Queensland代编,CSSE2310代编,CSSE7231代编,Computer Systems Principles and Programming代编,C代编,Real-time代编, online auction platform代编,The University of Queensland代考,CSSE2310代考,CSSE7231代考,Computer Systems Principles and Programming代考,C代考,Real-time代考, online auction platform代考,The University of Queenslandhelp,CSSE2310help,CSSE7231help,Computer Systems Principles and Programminghelp,Chelp,Real-timehelp, online auction platformhelp,The University of Queensland作业代写,CSSE2310作业代写,CSSE7231作业代写,Computer Systems Principles and Programming作业代写,C作业代写,Real-time作业代写, online auction platform作业代写,The University of Queensland编程代写,CSSE2310编程代写,CSSE7231编程代写,Computer Systems Principles and Programming编程代写,C编程代写,Real-time编程代写, online auction platform编程代写,The University of Queenslandprogramming help,CSSE2310programming help,CSSE7231programming help,Computer Systems Principles and Programmingprogramming help,Cprogramming help,Real-timeprogramming help, online auction platformprogramming help,The University of Queenslandassignment help,CSSE2310assignment help,CSSE7231assignment help,Computer Systems Principles and Programmingassignment help,Cassignment help,Real-timeassignment help, online auction platformassignment help,The University of Queenslandsolution,CSSE2310solution,CSSE7231solution,Computer Systems Principles and Programmingsolution,Csolution,Real-timesolution, online auction platformsolution,