Rewritten networking to use non-blocking sockets.

This fixes #592.
Fixed Linux compilation.
Squashed common code.
Merge pull request #595 from mc-server/NonBlockingSockets

Non blocking sockets