This new problem spawned from my previous topic (
https://coderanch.com/t/409993/java/java/Serialization-IOException-writeObject) about a Serialization problem with my networking project.
To summarize: My networking project is composed of two programs, a Server and a Client. Client requests a file to Server. If the file is available, Server sends packets (represented by an instance of a class I made called Frame) containing fragments of the file to Client and Client responds with an acknowledgment (ACK) for each packet. If the Server does not receive an ACK for a packet, that packet is retransmitted. The project should also be flexible enough to implement a sliding-window protocol (hence the use of threads).
Here is my implementation: I created a class called SendFrame which extends Thread. This class is responsible for transmitting and/or retransmitting (if ACK is not received) a Frame object (packet). The code inside the run() method is quite simple. The main idea is to keep retransmitting the packet until ACK is received. Pseudocode inside run() looks like this:
The server pseudocode looks like this:
simple pseudocode for Client:
My question: When Client receives a packet, is there a way for Client to awaken the sleeping Server so that it can receive the ACK? Also, I think my implementation feels awkward. Any tips or suggestions on making it better?