Commit b9d2f1e8 authored by iabdalkader's avatar iabdalkader Committed by Damien George

extmod/modusocket: Add timeout and callback to socket object.

parent 6841fecb
......@@ -86,9 +86,10 @@ typedef struct _mod_network_socket_obj_t {
uint32_t proto : 5;
uint32_t bound : 1;
int32_t fileno : 16;
int32_t timeout;
mp_obj_t callback;
#if MICROPY_PY_USOCKET_EXTENDED_STATE
// Extended socket state for NICs/ports that need it.
int32_t timeout;
void *state;
#endif
} mod_network_socket_obj_t;
......
......@@ -71,9 +71,9 @@ STATIC mp_obj_t socket_make_new(const mp_obj_type_t *type, size_t n_args, size_t
}
}
}
#if MICROPY_PY_USOCKET_EXTENDED_STATE
s->timeout = -1;
s->callback = MP_OBJ_NULL;
#if MICROPY_PY_USOCKET_EXTENDED_STATE
s->state = NULL;
#endif
......@@ -169,8 +169,9 @@ STATIC mp_obj_t socket_accept(mp_obj_t self_in) {
socket2->proto = self->proto;
socket2->bound = false;
socket2->fileno = -1;
#if MICROPY_PY_USOCKET_EXTENDED_STATE
socket2->timeout = -1;
socket2->callback = MP_OBJ_NULL;
#if MICROPY_PY_USOCKET_EXTENDED_STATE
socket2->state = NULL;
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment