I know I don’t need multiple threads for this, but I like to know if multithreading is possible?
I checked internet and people suggest there is no need for multi threading.
>Solution :
Yes, it is possible to use the select() function for multithreaded large-scale synchronous I/O multiplexing. The select() function is a system call that allows a program to monitor multiple file descriptor sources for events, such as data available to be read or space available to write data. It can be used to monitor multiple file descriptors in a single thread, allowing the thread to perform multiple I/O operations concurrently.
Using the select() function for multithreaded large-scale synchronous I/O multiplexing can be a good choice in certain situations, particularly when the program needs to scale to a large number of file descriptors and performance is a concern. However, there are some limitations to using select() that you should be aware of:
The select() function can only monitor a maximum of 1024 file descriptors on some systems, and this limit may be lower on other systems. This can be a problem if you need to monitor a large number of file descriptors.
The select() function is not efficient at handling a large number of file descriptors, as it requires the program to iterate over all of the file descriptors to check for events. This can lead to poor performance when monitoring a large number of file descriptors.
There are other alternatives to select() that you may want to consider if you are looking to perform multithreaded large-scale synchronous I/O multiplexing, such as the epoll() function or the poll() function. These functions can be more efficient at handling a large number of file descriptors, but may not be available on all systems.