Waits for a UDP discovery reply, and returns the sent data.
 @return [Array(String, Integer)] the IP and port received from the discovery reply.
517922
def receive_discovery_reply
      # Wait for a UDP message
      message = @socket.recv(70)
      ip = message[4..-3].delete("\0")
      port = message[-2..-1].to_i
      [ip, port]
    end
868413
def get_server_by_ip(self, ip_address):
        
        data = self.get_request('/ip_address/{0}'.format(ip_address))
        UUID = data['ip_address']['server']
        return self.get_server(UUID)
990620
def wait_for_responses(self, client):
        
        assert_open(self)

        if self.has_pending_requests:
            raise RuntimeError('Cannot wait for responses if there are '
                               'pending requests outstanding.  You need '
                               'to wait for pending requests to be sent '
                               'first.')

        pending = self.pending_responses
        self.pending_responses = []
        for command_name, options, promise in pending:
            value = client.parse_response(
                self.connection, command_name, **options)
            promise.resolve(value)
1135262
def result
      line = @sock.gets
      debug "< #{line}" if @debug
      raise Errno::ECONNRESET, "No response" unless line
      chr = line[0]
      if chr == '+'
        line[1..-1].strip
      elsif chr == '$'
        count = line[1..-1].strip.to_i
        return nil if count == -1
        data = @sock.read(count) if count > 0
        line = @sock.gets # read extra linefeeds
        data
      elsif chr == '-'
        # Server can respond with:
        #
        # -ERR Something unexpected
        # We raise a CommandError
        #
        # -NOTUNIQUE Job not unique
        # We return ["NOTUNIQUE", "Job not unique"]
        err = line[1..-1].split(" ", 2)
        raise CommandError, err[1] if err[0] == "ERR"
        err
      else
        # this is bad, indicates we need to reset the socket
        # and start fresh
        raise ParseError, line.strip
      end
    end
1096970
def system_address
      ::Socket.ip_address_list.find { |address|
        address.ipv4? && !address.ipv4_loopback?
      }.ip_address rescue nil
    end
556369
async def get_reply(self, message=None, *, timeout=None):
        
        return await self._get_message(
            message, self._reply_indices, self._pending_replies, timeout,
            lambda x, y: x.reply_to_msg_id == y
        )
422938
def lookup(item)
			# if item is an array, use it, otherwise make it one
			items = item
			if item.is_a? String
				items = [item]
			end
			# place the results in the results array
			results = []
			# for each ip or hostname
			items.each do |item|
				# sent is used to determine when we have all the answers
				sent = 0
				# record the start time
				@starttime = Time.now.to_f
				# determine the type of query
				itemtype = (item =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) ? 'ip' : 'domain'
				# for each dnsbl that supports our type, create the DNS query packet and send it
				# rotate across our configured name servers and increment sent
				@dnsbls.each do |name,config|
					next if config['disabled']
					next unless config['type'] == itemtype
					begin
						msg = _encode_query(item,itemtype,config['domain'],config['apikey'])
						@sockets[@socket_index].send(msg,0)
						@socket_index += 1
						@socket_index %= @sockets.length
						sent += 1
					rescue Exception => e
						puts e
						puts e.backtrace.join("\n")
					end
				end
				# while we still expect answers
				while sent > 0
					# wait on the socket for maximally 1.5 seconds
					r,_,_ = IO.select(@sockets,nil,nil,1.5)
					# if we time out, break out of the loop
					break unless r
					# for each reply, decode it and receive results, decrement the pending answers
					r.each do |s|
						begin
							response = _decode_response(s.recv(4096))
							results += response
						rescue Exception => e
							puts e
							puts e.backtrace.join("\n")
						end
						sent -= 1
					end
				end
			end
			results
		end
939921
def get_wan_ip(n=0):
    

    if n == 2:
        try:
            ip = myip()
            ip = extract_ip(ip)
            if is_ip_valid(ip):
                return ip
        except Exception as e:
            print(str(e))
            return None

    # Fail-safe: use centralized server for IP lookup.
    from pyp2p.net import forwarding_servers
    for forwarding_server in forwarding_servers:
        url = "http://" + forwarding_server["addr"] + ":"
        url += str(forwarding_server["port"])
        url += forwarding_server["url"]
        url += "?action=get_wan_ip"
        try:
            r = urlopen(url, timeout=5)
            response = r.read().decode("utf-8")
            response = extract_ip(response)
            if is_ip_valid(response):
                return response
        except Exception as e:
            print(str(e))
            continue

    time.sleep(1)
    return get_wan_ip(n + 1)
348911
def fetch(self):
        
        params = values.of({})

        payload = self._version.fetch(
            'GET',
            self._uri,
            params=params,
        )

        return IpAddressInstance(
            self._version,
            payload,
            account_sid=self._solution['account_sid'],
            ip_access_control_list_sid=self._solution['ip_access_control_list_sid'],
            sid=self._solution['sid'],
        )
1354704
def get_ip
      begin
        @logger.debug "Creating IP"
        ip = @compute_client.addresses.create
      rescue Fog::Compute::OpenStack::NotFound
        # If there are no more floating IP addresses, allocate a
        # new one and try again. 
        @compute_client.allocate_address(@options[:floating_ip_pool])
        ip = @compute_client.addresses.find { |ip| ip.instance_id.nil? }
      end
      raise 'Could not find or allocate an address' if not ip
      ip
    end
472752
function discover(waitForCount, callback) {
    var listenAddress='0.0.0.0';
    var listenPort=30000;
    var probePort=30050;
    var probeAddress='255.255.255.255';
    var probeAttempts=10;
    var probeInterval=500;
    var probeData = new Buffer('DAIKIN_UDP/common/basic_info');
    var probeTimeout;

    var discoveredDevices = {};

    var udpSocket = udp.createSocket({type:"udp4", reuseAddr:true});

    udpSocket.on('error', function (err) {
        console.log('ERROR udpSocket: ' + err);
    });

    udpSocket.bind(listenPort, listenAddress, function() {
        udpSocket.addMembership('224.0.0.1');
        udpSocket.setBroadcast(true);
    });

    udpSocket.on("message", function (message, remote) {
        console.log(remote.address + ':' + remote.port +' - ' + message);
        discoveredDevices[remote.address] = message.toString();
        if (Object.keys(discoveredDevices).length >= waitForCount) {
            finalizeDiscovery();
        }
    });

    udpSocket.on('listening', function() {
        sendProbes(probeAttempts);
    });

    function sendProbes(attemptsLeft) {
        probeTimeout = null;
        if (attemptsLeft > 0) {
            console.log('Send UDP discovery package ' + attemptsLeft);
            udpSocket.send(probeData, 0, probeData.length, probePort, probeAddress);
            probeTimeout = setTimeout(sendProbes, probeInterval, --attemptsLeft);
        }
        else {
            finalizeDiscovery();
        }
    }

    function finalizeDiscovery() {
        if (probeTimeout) clearTimeout(probeTimeout);
        udpSocket.close();
        console.log('Discovery finished with ' + Object.keys(discoveredDevices).length + ' devices found');
        callback(discoveredDevices);
    }
}
403161
def protocol(self):
        
        proto_id = self.lib.iperf_get_test_protocol_id(self._test)

        if proto_id == SOCK_STREAM:
            self._protocol = 'tcp'
        elif proto_id == SOCK_DGRAM:
            self._protocol = 'udp'

        return self._protocol
200429
def fetch(self):
        
        api = self.doapi_manager
        return api._floating_ip(api.request(self.url)["floating_ip"])
40003
def wait_until_online(function, ip, port):
    
    awaiting_service = Wait_For_State(lambda: not is_port_available(ip, port), function)
    awaiting_service.start()
    return awaiting_service
240775
def wait_for_net(self, timeout=None, wait_polling_interval=None):
        
        if timeout is None:
            timeout = self._timeout
        if wait_polling_interval is None:
            wait_polling_interval = self._wait_polling_interval

        self._logger.info("Waiting for network connection")
        poll_wait(self.get_ip_address, timeout=timeout)
134756
def discover(self):
        
        if self.transport:
            if self.discovery_countdown <= 0:
                self.discovery_countdown = self.discovery_interval
                msg = GetService(BROADCAST_MAC, self.source_id, seq_num=0, payload={}, ack_requested=False, response_requested=True)
                self.transport.sendto(msg.generate_packed_message(), (self.broadcast_ip, UDP_BROADCAST_PORT))
            else:
                self.discovery_countdown -= self.discovery_step
            self.loop.call_later(self.discovery_step, self.discover)
141953
def _get_ids_from_ip(self, ip):  # pylint: disable=inconsistent-return-statements
        """"""
        try:
            # Does it look like an ip address?
            socket.inet_aton(ip)
        except socket.error:
            return []

        # Find the server via ip address. First try public ip, then private
        results = self.list_hardware(public_ip=ip, mask="id")
        if results:
            return [result['id'] for result in results]

        results = self.list_hardware(private_ip=ip, mask="id")
        if results:
            return [result['id'] for result in results]