scieslak / distance_finder

Get distance and travel time between almost any two places on the globe.
MIT License
0 stars 0 forks source link

Unnecessary socket use #3

Open ttrmw opened 7 years ago

ttrmw commented 7 years ago

It isn't really necessary to instantiate a socket directly in order to check for a connection, can you think of a cleaner way to achieve correct error handling?

scieslak commented 7 years ago

Thank you very much for that challenge @ttrmw. I will be honest. I had a quite hard time with providing a better solution. I was googling around, and I think I would possibly use Timeout::timeout. However, a little clue to push me in the right direction would be greatly appreciated. For the time being, I have extracted socket instantiation to a separate method connection? which I believe looks a little bit cleaner.