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

This prevents deadlocks from libc locks when interrupting.
Merge pull request #1413 from BrzVlad/bin-prot-io

System calls for binary protocol writing