Normalize line endings
Check if socket is initialized before use

fixes #325