Improved socket handling

- separate timeouts for connecting and receiving
- exception handling for connection setup