Socket can clear buffer. termios module has some terminal interface functions.

Lawn Fungus