CS865 –
Distributed Software Development
|
Socket
Assignment
|
Complete the following assignment
and email the report, source, and executable code to fmarchese@pace.edu
1. This exercise deals with the
connectionless datagram socket via code sample Example1 of the Sockets lecture.
As a start, it is recommended that you run both programs on one machine,
the host name of which you may refer to as “localhost”, as in the command “java Example1Sender localhost 12345
hello” to execute Example1Sender. You may optionally repeat the exercises by
running the programs on separate machines, assuming that you have access to
such machines.
a. Compile the .java files. Then run the two
applications by (i) executing the receiver, then (ii)
executing the sender, taking care to specify the appropriate command line
arguments in each case. The message sent
should not exceed the maximum length allowed in the receiver (that is, 10
characters). Describe the outcome of the
run.
b. Re-run the applications – this time
reverse the order of the steps (i) and (ii). Describe and explain the outcome.
c. Repeat a, this time sending a
message of length greater than the maximum length allowed (say “01234567890”). Describe and explain the outcome.
d. Modify the original Example 1 code so that the sender also
receives a message from the receiver.
You should only need one socket only in each process. Compile, run, and turn in your code; be sure
to modify the comments accordingly.
2. Modify Example5*.java so that
the ConnectionRequestor sends a replying message to
the ConnectionAcceptor after receiving a message from
the Acceptor. The replying message
should be displayed by the Acceptor.