Rewritten to kill busyloop.

Had to reimlpement socket handling using stream_*, which means that there's
no need for composer anymore.