Separate ping and read loop. Added read socket timeouts.