extmod/modusocket: Add timeout and callback to socket object.
This commit is contained in:
parent
6841fecbb2
commit
b9d2f1e844
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue