Final answer:
To create the server, you'd need to implement socket creation and management, multithreading for handling client connections, and file processing operations to compute the file statistics, all while adhering to correct network communication protocols.
Step-by-step explanation:
To write a server that meets the specified criteria, you would need to implement several key functionalities. First, the server should bind a port to initiate the server process. Once the server is running, it should be prepared to accept connections from clients. As clients connect, the server will need to create new client-handling threads to manage multiple connections efficiently.
When a client connects, the server should use the socket's READ method to receive an integer in network byte order, which specifies the length of a subsequent string. Then, the server should read the string from the socket, which represents the file extension to search for.
The server should then iterate over the current directory, counting the number of files with the specified extension, and aggregate the total number of lines, words, and characters across all these files.
Finally, the server compiles these counts into a response and sends the data back to the client, ensuring the integers are converted to network byte order before transmission. The steps involve the concepts of socket programming, multithreading, file I/O operations, string manipulation, and network communication.