The (IAC) part in the rfc is just a help for the reader, not part of the actual program. What you need to send is ONLY a $chr(255) (that's one byte), just like you send only one character $cr and not "$cr (CARRIAGE RETURN)" (19 characters on quick count)

on *:SOCKLISTEN:telnet:{
sockaccept client
sockwrite -n client $chr(255) $+ $chr(251) $+ your stuff here
}