[sgen] Fix binary protocol build
[sgen] Don't use standard C API for binary protocol IO.

This prevents deadlocks from libc locks when interrupting.