
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

This exercise guides you through experiments with connection-oriented datagram socket using code sample Example4.java and Example5.java. You may download the example code from the class website: http://www.cecs.csulb.edu/~jpark/cecs327/codeSample/Ch4/Example4-5/ a) Compile and run _Example4.java._ Start the Acceptor first, then the Requestor. Sample commands to do so are: $ Java Example4ConnectionAcceptor 12345 Good-day! $ Java Example4ConnectionRequestor localhost 12345 Describe and explain the outcome. b) Re-run the applications โ this time reverse the order of the steps (i) and (ii). Describe and explain the outcome. c) Add a time delay of 5 seconds (by using Thread.sleep( )) in ConnectionAcceptor just before the message is written to the socket. This will have the effect of keeping the Requestor blocked on reading for 5 extra seconds so that you can observe the blocking visually. Do the diagnostic messages displayed on screen agree with the event diagram in Figure 4.21? d) Modify _Example4.java_ so that the ConnectionAcceptor uses print( ) to write one character at a time to the socket before issuing a printlin( ) to write an end-of-line. Recompile and run the programs. Does the message still get received in its entirety? Explain. e) 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. Hand in an event diagram, the program listings, and run outcome.