socket recv timeout added to periodically check if a stop() is requested