How to interrupt input
===

I am implementing a client which uses two threads: one that receives data from a server and prints it to stdout, the other one uses fgets to ask a string to the user and sends a message to the server.The threads are always in execution, but there is a problem: I don't know how to stop the thread that takes input from the user.I tried closing stdin with fclose, but the stream remains opened until the user digits a string.How is possibile to close the input buffer in a way that fgets is interrupted?  
I hope the question is clear.