Correct setsockopt() uses.
Use StringBuffer in text_input_show().
Add sanity checks.