After determining the port, call the accept () method using ServerSocket. In this way, the server will be blocked at accept () until a client requests it, and then it will continue to be executed. Later, you can write specific logic code to get the contents of the folder, and then write it into the stream and send it back to the client.
2. Customers
Every once in a while, there are many ways to achieve customer requirements. For example, just write a timer and send a request to the server at a specified time interval. Specifically, after connecting a new Socket(ip, port), you can read the data written by the server.
The middle details can be figured out by yourself, and the loop can be realized by multithreading.
The specific usage of Socket can be found in the official api or google.