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
cff4ad88
Commit
cff4ad88
authored
Jul 18, 2009
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
socket.py: add create_connection_ssl, similar to create_connection
parent
695f4397
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
gevent/socket.py
gevent/socket.py
+29
-0
No files found.
gevent/socket.py
View file @
cff4ad88
...
...
@@ -467,6 +467,35 @@ def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT):
raise
error
,
msg
def
create_connection_ssl
(
address
,
timeout
=
_GLOBAL_DEFAULT_TIMEOUT
):
"""Connect to *address* and return the socket object.
Convenience function. Connect to *address* (a 2-tuple ``(host,
port)``) and return the socket object. Passing the optional
*timeout* parameter will set the timeout on the socket instance
before attempting to connect. If no *timeout* is supplied, the
global default timeout setting returned by :func:`getdefaulttimeout`
is used.
"""
msg
=
"getaddrinfo returns an empty list"
host
,
port
=
address
for
res
in
getaddrinfo
(
host
,
port
,
0
,
_socket
.
SOCK_STREAM
):
af
,
socktype
,
proto
,
canonname
,
sa
=
res
sock
=
None
try
:
_sock
=
_original_socket
(
af
,
socktype
,
proto
)
sock
=
wrap_ssl000
(
_sock
)
if
timeout
is
not
_GLOBAL_DEFAULT_TIMEOUT
:
sock
.
settimeout
(
timeout
)
sock
.
connect
(
sa
)
return
sock
except
error
,
msg
:
if
sock
is
not
None
:
sock
.
close
()
raise
error
,
msg
# get rid of this
def
wrap_ssl000
(
sock
,
keyfile
=
None
,
certfile
=
None
):
from
OpenSSL
import
SSL
...
...
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