Removed multiple exceptions for socket;
Code reformatted.