Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
8c9758ff
Commit
8c9758ff
authored
May 28, 2019
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unix/modusocket: Raise ETIMEDOUT when connect or accept has timeout.
parent
887a6712
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
ports/unix/modusocket.c
ports/unix/modusocket.c
+12
-2
No files found.
ports/unix/modusocket.c
View file @
8c9758ff
...
...
@@ -160,7 +160,12 @@ STATIC mp_obj_t socket_connect(mp_obj_t self_in, mp_obj_t addr_in) {
mp_buffer_info_t
bufinfo
;
mp_get_buffer_raise
(
addr_in
,
&
bufinfo
,
MP_BUFFER_READ
);
int
r
=
connect
(
self
->
fd
,
(
const
struct
sockaddr
*
)
bufinfo
.
buf
,
bufinfo
.
len
);
RAISE_ERRNO
(
r
,
errno
);
int
err
=
errno
;
if
(
r
==
-
1
&&
self
->
blocking
&&
err
==
EINPROGRESS
)
{
// EINPROGRESS on a blocking socket means the operation timed out
err
=
MP_ETIMEDOUT
;
}
RAISE_ERRNO
(
r
,
err
);
return
mp_const_none
;
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_2
(
socket_connect_obj
,
socket_connect
);
...
...
@@ -190,7 +195,12 @@ STATIC mp_obj_t socket_accept(mp_obj_t self_in) {
byte
addr
[
32
];
socklen_t
addr_len
=
sizeof
(
addr
);
int
fd
=
accept
(
self
->
fd
,
(
struct
sockaddr
*
)
&
addr
,
&
addr_len
);
RAISE_ERRNO
(
fd
,
errno
);
int
err
=
errno
;
if
(
fd
==
-
1
&&
self
->
blocking
&&
err
==
EAGAIN
)
{
// EAGAIN on a blocking socket means the operation timed out
err
=
MP_ETIMEDOUT
;
}
RAISE_ERRNO
(
fd
,
err
);
mp_obj_tuple_t
*
t
=
MP_OBJ_TO_PTR
(
mp_obj_new_tuple
(
2
,
NULL
));
t
->
items
[
0
]
=
MP_OBJ_FROM_PTR
(
socket_new
(
fd
));
...
...
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