Flush I/O data on connect

Make sure there is no stale I/O data on tty device upon connect.