Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
20197c88
Commit
20197c88
authored
Nov 19, 1997
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add s.connect_ex() which returns errno instead of raising an exception.
parent
671428ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
Modules/socketmodule.c
Modules/socketmodule.c
+20
-0
No files found.
Modules/socketmodule.c
View file @
20197c88
...
...
@@ -66,6 +66,7 @@ Socket methods:
- s.bind(sockaddr) --> None
- s.close() --> None
- s.connect(sockaddr) --> None
- s.connect_ex(sockaddr) --> 0 or errno (handy for e.g. async connect)
- s.fileno() --> file descriptor
- s.dup() --> same as socket.fromfd(os.dup(s.fileno(), ...)
- s.getpeername() --> sockaddr
...
...
@@ -681,6 +682,25 @@ BUILD_FUNC_DEF_2(PySocketSock_connect,PySocketSockObject *,s, PyObject *,args)
}
/* s.connect_ex(sockaddr) method */
static
PyObject
*
BUILD_FUNC_DEF_2
(
PySocketSock_connect_ex
,
PySocketSockObject
*
,
s
,
PyObject
*
,
args
)
{
struct
sockaddr
*
addr
;
int
addrlen
;
int
res
;
if
(
!
getsockaddrarg
(
s
,
args
,
&
addr
,
&
addrlen
))
return
NULL
;
Py_BEGIN_ALLOW_THREADS
res
=
connect
(
s
->
sock_fd
,
addr
,
addrlen
);
Py_END_ALLOW_THREADS
if
(
res
!=
0
)
res
=
errno
;
return
PyInt_FromLong
((
long
)
res
);
}
/* s.fileno() method */
static
PyObject
*
...
...
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