rewrote sockRecv and added handlePacket methods