Bug in stream shutdown fixed.

This fix makes initial header exchange to proceed in two
steps. First the header is sent. When done, header from the peer is received.
Due to async nature of TCP and UNIX domain sockets, the change
of algorithm has no impact on performance.

This patch solves several issues in the bug tracker.

Signed-off-by: Martin Sustrik <sustrik@250bpm.com>