The server is in its set Call “listen” on the socket. When the client connects, it will generate a new object of the Client class. The new object runs in its own thread and processes the client’s request.
When the client is disconnected When connecting, I want some way to tell my main() thread that this thread has completed, and main() can delete this object and record something like “Client disconnected”.
My question is , How do I tell the main thread that the thread has completed?
Alternatively, you can use some shared variables and mutexes to complete certain operations.
< /div>
I have a TCP server application that uses POSIX threads and C to serve each client in the new thread.
The server is in its socket Call “listen” literally, when the client connects, it will generate a new object of the Client class. The new object runs in its own thread and processes the client’s request.
When the client disconnects When I want some way to tell my main() thread that this thread has completed, and main() can delete this object and record something like “Client disconnected”.
My question is, How do I tell the main thread that the thread has completed?
The easiest way I can see is to join the thread. See here. The idea is that in the connection call, the command thread will wait for the worker thread Exit and continue.
Alternatively, you can use some shared variables and mutexes to complete certain operations.
WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3012 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC