How to use the pycares.ARES_NI_NUMERICSERV function in pycares

To help you get started, we’ve selected a few pycares examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github saghul / pycares / tests / tests.py View on Github external
def test_getnameinfo_ipv6_ll(self):
        self.result, self.errorno = None, None
        def cb(result, errorno):
            self.result, self.errorno = result, errorno
        self.channel.getnameinfo(('fe80::5abd:fee7:4177:60c0', 80, 0, 666), pycares.ARES_NI_NUMERICHOST|pycares.ARES_NI_NUMERICSERV|pycares.ARES_NI_NUMERICSCOPE, cb)
        self.wait()
        self.assertNoError(self.errorno)
        self.assertEqual(type(self.result), pycares.ares_nameinfo_result)
        self.assertEqual(self.result.node, 'fe80::5abd:fee7:4177:60c0%666')
        self.assertEqual(self.result.service, '80')
github saghul / uvent / uvent / resolver.py View on Github external
import pycares
import pyuv
import socket

from collections import namedtuple
from functools import partial
from gevent.hub import get_hub, Waiter


Result = namedtuple('Result', ['value', 'exception'])

class Resolver(object):

    _ares_flag_map = [(getattr(socket, 'NI_NUMERICHOST', 1), pycares.ARES_NI_NUMERICHOST),
                      (getattr(socket, 'NI_NUMERICSERV', 2), pycares.ARES_NI_NUMERICSERV),
                      (getattr(socket, 'NI_NOFQDN',      4), pycares.ARES_NI_NOFQDN),
                      (getattr(socket, 'NI_NAMEREQD',    8), pycares.ARES_NI_NAMEREQD),
                      (getattr(socket, 'NI_DGRAM',      16), pycares.ARES_NI_DGRAM)]

    _ares_errno_map = {pycares.errno.ARES_ENOTFOUND: (socket.gaierror, (8, 'nodename nor servname provided, or not known')),
                       pycares.errno.ARES_ENODATA: (socket.gaierror, (8, 'nodename nor servname provided, or not known'))}
    _ares_errno_map2 = {pycares.errno.ARES_ENOTFOUND: (socket.herror, (1, 'Unknown host')),
                        pycares.errno.ARES_ENODATA: (socket.gaierror, (8, 'nodename nor servname provided, or not known'))}
    _addrinfo_errno_map = {pyuv.errno.UV_ENOENT: (socket.gaierror, (8, 'nodename nor servname provided, or not known'))}

    def __init__(self, hub=None):
        self.hub = hub or get_hub()
        self._channel = pycares.Channel(sock_state_cb=self._sock_state_cb)
        self._timer = pyuv.Timer(self.hub.loop._loop)
        self._fd_map = {}