How to calculate the activity of sockfd

this is true. I would like to add a function: the server creates a timer thread to regularly poll to detect sockfd activity, shutting down sockfd that has not been active for a long time
but I don"t know how to judge whether a sockfd is active or not. How can I calculate how long it has been since the last io operation?

Menu