import java.io.*;
import java.net.*;
public class Server {
public static void main(String[] args) {
try {
ServerSocket serverSocket = new ServerSocket(8080);
System.out.println("Server started. Waiting for client connection...");
Socket socket = serverSocket.accept();
System.out.println("Client connected.");
ObjectInputStream in = new ObjectInputStream(socket.getInputStream());
ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream());
int windowSize = in.readInt();
int numFrames = in.readInt();
String[] frames = (String[]) in.readObject();
System.out.println("Sliding Window ARQ Protocol initiated on the server side.");
System.out.println("Window size: " + windowSize);
System.out.println("No. of frames: " + numFrames);
for (int i = 0; i < numFrames; i++) {
System.out.println("The received Frame " + i + " is: " + frames[i]);
}
int ackNumber = numFrames;
out.writeInt(ackNumber);
out.flush();
System.out.println("Acknowledgement number: " + ackNumber);
in.close();
out.close();
socket.close();
serverSocket.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}