You are trying to set up terminal characteristics for a device which is not a terminal.
Recode your program.