Socket code reshuffled a bit
IP detection via recvfrom