Catch socket exceptions