Joomla Vorlagen by Website Hosting

PJ1 - 12th laboratory (TCP/IP)

pl1-lab12.zip

pl1-lab12-solution.zip

TCP/IP

1. Create a "Server" that opens the server socket on port "11111" and expects a client connection. Writes one byte (random value) when connected.

2. Create a client that connects and retrieves one byte from the server.

3. Modify the previous program so that the server sends an instance of the MessageDTO class to the client (use serialization).

4. Modify that the MessageDTO class object sends the client, the server modifies the data, and sends it back.

Thread

5. Ensure that the server is handling separate thread requests (use Thread).

6. Try a naive Pool implementation for the producer-consumer example - view the CPU load on the system.

7. Try deleting the volatile keyword for the full flag in the NaivePool class and observe the behavior change (use JDK8 or higher). Try explaining what is causing this change.

8. Implement the Pool type using synchronized, wait and notifyAll. Observe the difference in CPU load.

Homework

CREATE A NEW PROJECT - DO NOT USE CLASSES FROM A PROJECT WHICH WAS EXERCISE.

Create a "chat" program for two users. The program is started from the command line. Parameter specifies:

  • Whether it runs in server or client mode
  • Port number
  • nickname,
  • if it is running in client mode, it also addresses the remote computer where the server part is running.

The program will work very simply - everything that is loaded from the console from the user is forwarded via an open connection to the remote side (it will be read line by line and a nickname will be added). Everything that is retrieved from a stream that travels from the far side is written to the console.

The program terminates when the remote party closes the connection (END-OF-FILE from the strike occurs), or the user writes the string "END OF SESSION" to the console.