|
| Budget: |
$ 20-100 |
| Status: |
Closed
for Bidding (selected
user roybuet)
|
| Project
Creator: |
|
| |
Rating: (No Feedback Yet)
|
| Required
Skills: |
,
,
|
| Attached
Files: |
(None) |
 |
|
|
|
|
|
|
|
|
|
|
Description
In this assignment, you will use sockets to write a simple client-server application to play a Lottery. You should select 6 distinct numbers in the range 1-100 and you win if any one of those numbers matches the single number generated at random by the Server. The client/server action should proceed as follows: Client c1. Connect to server via a connection-oriented socket. c2. Read (from socket) and display the prompt message sent (see step s2 in server) by the server. c3. Input your six lottery selections and send them to the server. c4.Read (from socket) and display the result of the game, or an error message that is returned by the server (see step s4 in server). c5. Close the connection Server s0. [Initialization] Create a socket on one of the port numbers in the range above 1024. s1.Wait for a client connection on this socket s2.When a client connection is accepted send an acknowledgement as a string of text. s3. Receive and read the list of numbers selected by the client. Check that this list is valid (distinct numbers in the range 1-100), if not, return an error message. s4. Make the lottery draw and see if the client has any winning numbers. Return the result to the client. s5. Close the connection to the client and then loop back and wait for another connection. Programming notes Here are a few tips/thoughts to help you with this assignment: · You must chose an unused server port number above 1024. For example, choose port 8888. · The Server application listens on port 8888 and handles the incoming requests. It may consist of several classes, one to listen, accept connections and revert to listening, and one to draw the lottery number and check whether any client choices have won. The Server should print diagnostic information on the terminal (no GUI is required), listing the status of the server and details of each connection. For example: Server listening on Port 8888, IP number of Client, Connection accepted. It may be helpful to test your Server using telnet before attempting to connect to the client. · Write a Client application, which consists of a GUI containing fields to insert the six choices and a ‘Submission’ button that must be clicked to send them. There should also be a field indicating whether any of your choices has won. A 'Quit' button would also be good programming practice. · In writing your code, make sure to check for an error return from your system calls or method invocations, and display an appropriate message. In Java, this means using IOException(); · Most of you will be running both the client and server on the same machine. Start the server in one window, and then start the client in another window. In the socket, use ‘localhost’ as the name of the machine to connect to. · Make sure you close every socket that you use in your program. If you abort your program, the socket may still hang around and the next time you try and bind a new socket to the port you previously used (but never closed), you may get an error. Also, please be aware that port ID's, when bound to sockets, are systemwide values and in the UNIX lab other students may be using the port number you are trying to use. Extensions A small number of marks are reserved for extensions. These could be to make the Server multithreaded, or to send the range of possible number choices to the client and validate entries there.
Reminder
You may not start working in this and any project before
your bid is accepted. Any user who violates this policy
may have their account permanently suspended.
|