diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-02-08 21:15:46 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-02-08 21:20:32 +0200 |
commit | 1e19b24ea0081cde0cbccfecd9698a0b55a4450c (patch) | |
tree | 12b6267e13b3b4aae7e2cc4642f95cc3b8b72c53 /unix/socket.c | |
parent | 9945f338863cd1bc0ce483c0eb70c41fbdb710f1 (diff) | |
download | micropython-1e19b24ea0081cde0cbccfecd9698a0b55a4450c.tar.gz micropython-1e19b24ea0081cde0cbccfecd9698a0b55a4450c.zip |
io.File, socket types: Add fileno() method.
Implementation is duplicated, but tolerate this for now, because there's
no clear idea how to de-dup it.
Diffstat (limited to 'unix/socket.c')
-rw-r--r-- | unix/socket.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/unix/socket.c b/unix/socket.c index c38e38a0a1..aaa15cbee2 100644 --- a/unix/socket.c +++ b/unix/socket.c @@ -84,6 +84,12 @@ static mp_obj_t socket_close(mp_obj_t self_in) { } static MP_DEFINE_CONST_FUN_OBJ_1(socket_close_obj, socket_close); +static mp_obj_t socket_fileno(mp_obj_t self_in) { + mp_obj_socket_t *self = self_in; + return MP_OBJ_NEW_SMALL_INT(self->fd); +} +static MP_DEFINE_CONST_FUN_OBJ_1(socket_fileno_obj, socket_fileno); + static mp_obj_t socket_connect(mp_obj_t self_in, mp_obj_t addr_in) { mp_obj_socket_t *self = self_in; buffer_info_t bufinfo; @@ -209,6 +215,7 @@ static mp_obj_t socket_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const } static const mp_method_t microsocket_type_methods[] = { + { "fileno", &socket_fileno_obj }, { "read", &mp_stream_read_obj }, { "readall", &mp_stream_readall_obj }, { "readline", &mp_stream_unbuffered_readline_obj}, |