You have chosen to sponsor your bid up to a maximum amount of .
You are required to write Java programs using BSD sockets to implement a simple online telephone directory system. Two applications (client and server) using TCP connection are required. The client application (named client-phonedb) allows users to query and update the telephone database depending on user type (i.e. general user, administer). The system administer is identified by providing the correct access code (any combinations of alphanumeric characters) in the command line for client. The actions (determined by command line option) to be performed by client are listed below:
---query telephone number:
client-phonedb -h host -p port -q name
---delete a record (for system administer only):
client-phonedb -h host -p port -d name -s accessCode
---add a record (for system administer only):
client-phonedb -h host -p port -a "name & phoneNo" -s accessCode
---list all records and save in client side as a file (for system administer only):
client-phonedb -h host -p port -l filename.log -s accessCode
Once the server application (named server-yp) starts, it listens for a request, processes the request, sends the response and waits for the next request. It should not exit for any abnormal client operations. After processing a client request, the server should also inform the client whether the request was processed successfully or not. When the server application initiates (at a port number specified in command line option -p), the telephone database is loaded into internal memory from an external ASCII text file (specified in command line option -f):
server-phonedb -p port -f DBfilename.txt -o Logfilename.txt
Update of the database by client operations are performed only in physical memory of the server machine (i.e. no need to save records in file). You may use any data structure (e.g. array or list) to implement the database. Every update operations (i.e. delete, add) have to be recorded in the log file (specified in command line option -o). For server management you should also record any abnormal client request. In the log file you should record
date & time for client request
details of the record being updated
client IP address and port number
You have to design the record format of the input telephone directory text file, but the format must be the SAME as that obtained by client action (4)--list all records. Each record should contain the following fields:
There are some situations that you have to take into considerations when writing the client/server applications. When a client has sent a request, it waits for a response. Should the client waits forever? In other words, is it necessary to handle message lost/duplication? If yes, how?
1>The client/server accepts optional command line parameters properly.
2>The client/server choose sensible defaults for optional command line arguments.
3> Client requests to query a phone number
4> Client requests to update a record
5> Client requests to add a record
6> Client requests to list all records and save in file
7> Server operations on telephone database required for each client request
8> Server saves transaction details in log file
9> Strategy to handle message lost/duplication
10> Error handling in client/server
What to Hand In
The deliverables are:
Client source code
Server source code
report explaining sample runs, error handling and handling of message lost/duplication
As usually, we expect well commented code with descriptive identifier names and neat presentation.