Fix handling socket errors.
Add test.
Bump version.
Fix closing sockets when api demands it.
Merge pull request #5 from kramarz/master

Fix sockets.