factoring out socket finder