Here`s

advertisement
Minor Assignment N+1 – A Socket Implementation of Client/Server
In this assignment you will build a C program to support a client/server model for
theatre tickets. I have given you C code for a simple client/server that merely
passes a message back and forth and I anticipate that you’ll embellish that program,
but you can start from scratch if you want. You should submit exactly ONE solution
for this assignment (to Blackboard of course) per project group. So, you’re to do this
assignment in your project teams.
So, here’s the application. There will be a “main” ticket outlet (the server) that will
provide services to two “local” ticket distributors. Here’s what the system will
support.

Server
o Will “generate” N tickets
o When asked for a ticket, will look to see if any remain. If so will return
the ticket number. If no tickets remain, will return a value to indicate
that all tickets are gone. But it will NOT close up shop at that point,
because some ticket(s) might be returned.
o When a client returns a ticket, the server will “place” it back in the
ticket pool, hopefully to be passed out later.
o When no client remains “connected” to the server it will shut down.

Clients (there will be two of these)
o Will request a ticket from that Server
o May, from time to time, return a ticket to the Server
o When all of the client requests have been granted the client will
disconnect from the server.
You program should have the server and each of two clients executing on three
different (CSE) machines at the same time.
To make things a bit interesting:
 the Server will start with 25 tickets,
 each client will make 15 requests,
 80% of the client requests should ask for a ticket and 20% (chosen
“randomly”) should be to return a ticket. Of course this random distribution
should be supported in your program by an appropriate use of a pseudorandom number generator available in C. (I recommend “random”.)
Two things to consider: Given the randomness of the requests it COULD be that not
all client requests will be met. AND, don’t be too surprised if your program gives
you some strange output (sometimes). For instance, given the instructions I’ve
given you, you MIGHT see the same ticket given to both clients. Think about how
that might happen? If you see that or other strange behavior at run time do not
NECESSARILY think its an error in your program. This does NOT mean that any
output errors will be ignored by the grader. Just a few “special” ones, possibly.
You can find currently working code for one server and one client available at:
~phs0004/public/3600/sockets
Submit a .tar.gz (or similar file) to Blackboard on or before 11:59pm on 11/30/15.
We’ll spend time in class on 12/1/15 “adjusting” a working program to make it
more functional.
Download