Added socket error handling
Merge pull request #50 from luizmineo/master

Add socket error handling