代做MINT 706 (LEC B1 Winter 2024) Programming Assignment Description代写留学生Java程序

- 首页 >> Web

You are asked to implement a client-server-based Internet application.

The server is similar to the daytime server except that it is a "seat availability for a shuttle bus" server.  Your implementation does not need to report the actual number of seats available; the number of available seats always starts at 20.

NOTE:  Many bus companies (e.g., at airports) have some kind of online reservation system these days.

A client can connect to the server and make one of two different requests:

1. ask:  The client can ask for the number of available seats.  The server responds with an appropriate string, like: "Shuttle Bus has 20

seats available." Your string should look exactly like this string, except the number "20" should be the correct number.  Asking for the number of available seats does not change the count of available seats.

2. reserve:  The client can ask to reserve a seat.  If a seat is available, the server subtracts one seat count and responds with an appropriate string,    like: "Seat Reserved. Shuttle Bus now has 19 seats available." Your string should look exactly like this string, except the number " 19" should be the correct number.  If there is no seat available (i.e., the count is already zero), then your server should respond      with "Failed Reservation."

For this simplified server, there is no way to release a seat and increase the count.  Note that the 3 possible messages above are of variable length.

The server should be runnable from the command line with:

unix-prompt% edm.server

and it should print out the IP address of the machine it is running on and port number it is listening on. See my example program in getIPAddress.c.  For example, something like:

EDM is running on 129.128.4.80, listening on port 24459

If your Unix machine (e.g., Linux under virtual machine) is causing your server problems with respect to the IP address of the server's machine, it is OK to print:

EDM is running on local host, listening on port 24459

and then to have the user find the actual IP address of the server/local machine using Unix's ifconfig command.

Each time that the server starts, it considers 20 seats to be available.

The client should be runnable from the command line with either:

unix-prompt% edm.client 129.128.4.80 24459 ask

or

unix-prompt% edm.client 129.128.4.80 24459 reserve

since, of course, the client needs to know the well-known location of the server process (i.e., both IP address and port number) .

If called with the "ask" command-line argument, the client will just ask the server for the number of available seats.  The client will then print out the return string from the server, exactly as sent from the server.  Then, the client will exit.

If called with the "reserve" command-line argument, the client will ask the server to reserve a seat.  The client will then print out the return string from the server, exactly as sent from the server.  Recall that a reserve request can fail with a specific kind of return string.  Then, the client will exit.

Use any reasonable format for the message between client-and-server and between server-and-client. You may use any source code, with proper acknowledgement , from Jim Frost, Paul Lu, or our textbook.

The following elements are required of your programs (i.e., client program and server program):

1. Use the UNIX Socket API with TCP/IP-based sockets (i.e ., AF_INET) such that the client and server can be on different computer systems.

2. As discussed in class, it is strongly, strongly preferred that you write your programs in the C language. Python and Java implementations are also acceptable.  If you wish to use a different language, please contact the instructor first.

3. Write your programs for Linux or any Unix-like operating system. If you wish to use a different operating system, please contact the instructor first.

4. Provide instructions or a script. for how to compile your program. A Unix-like Makefileis the preferred way.

5. Be sure to comment your code to make it more understandable. In particular, comment on the message formats used.

6. Submit all source code les (i.e.,  .c,  .h, and Makefile) to your instructor.




站长地图