Fix pointer conversion warnings
Check for headers which may or may not be available
Whitespace fix
Workaround for Solaris libc

The Solaris libc has some issues with alternating input and output
on sockets passed to fdopen(). Apparently there is a shared buffer
which has to be emptied, either by fseek() or fflush(), whenever
the direction of the data flow changes.
Flush before waiting for new input, not after
Merge pull request #1 from roehling/master

Update