Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
31651a66
Commit
31651a66
authored
Apr 20, 2011
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resolver_ares: extract _lookup_port for getaddrinfo
parent
8626da67
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
10 deletions
+15
-10
gevent/resolver_ares.py
gevent/resolver_ares.py
+15
-10
No files found.
gevent/resolver_ares.py
View file @
31651a66
...
...
@@ -27,16 +27,7 @@ class Resolver(object):
self
.
ares
.
gethostbyname
(
waiter
,
hostname
,
family
)
return
waiter
.
get
()
def
getaddrinfo
(
self
,
host
,
port
,
family
=
0
,
socktype
=
0
,
proto
=
0
,
flags
=
0
):
if
isinstance
(
host
,
unicode
):
host
=
host
.
encode
(
'idna'
)
elif
not
isinstance
(
host
,
str
)
or
(
flags
&
AI_NUMERICHOST
):
# this handles cases which do not require network access
# 1) host is None
# 2) host is of an invalid type
# 3) AI_NUMERICHOST flag is set
return
getaddrinfo
(
host
,
port
,
family
,
socktype
,
proto
,
flags
)
# we also call _socket.getaddrinfo below if family is not one of AF_*
def
_lookup_port
(
self
,
port
,
socktype
):
if
isinstance
(
port
,
basestring
):
try
:
if
socktype
==
0
:
...
...
@@ -59,6 +50,20 @@ class Resolver(object):
raise
gaierror
(
str
(
ex
))
elif
port
is
None
:
port
=
0
return
port
,
socktype
def
getaddrinfo
(
self
,
host
,
port
,
family
=
0
,
socktype
=
0
,
proto
=
0
,
flags
=
0
):
if
isinstance
(
host
,
unicode
):
host
=
host
.
encode
(
'idna'
)
elif
not
isinstance
(
host
,
str
)
or
(
flags
&
AI_NUMERICHOST
):
# this handles cases which do not require network access
# 1) host is None
# 2) host is of an invalid type
# 3) AI_NUMERICHOST flag is set
return
getaddrinfo
(
host
,
port
,
family
,
socktype
,
proto
,
flags
)
# we also call _socket.getaddrinfo below if family is not one of AF_*
port
,
socktype
=
self
.
_lookup_port
(
port
,
socktype
)
socktype_proto
=
[(
SOCK_STREAM
,
6
),
(
SOCK_DGRAM
,
17
),
(
SOCK_RAW
,
0
)]
if
socktype
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment