removed test code and moved socket stuff to where it will be when we can determine the closest device