@@ -198,12 +198,34 @@ STATIC mp_obj_t socket_send(const mp_obj_t arg0, const mp_obj_t arg1) {
198
198
}
199
199
STATIC MP_DEFINE_CONST_FUN_OBJ_2 (socket_send_obj , socket_send );
200
200
201
+ STATIC mp_obj_t socket_sendall (const mp_obj_t arg0 , const mp_obj_t arg1 ) {
202
+ // XXX behaviour when nonblocking (see extmod/modlwip.c)
203
+ // XXX also timeout behaviour.
204
+ socket_obj_t * self = MP_OBJ_TO_PTR (arg0 );
205
+ mp_buffer_info_t bufinfo ;
206
+ mp_get_buffer_raise (arg1 , & bufinfo , MP_BUFFER_READ );
207
+ while (bufinfo .len != 0 ) {
208
+ int ret = lwip_write (self -> fd , bufinfo .buf , bufinfo .len );
209
+ if (ret < 0 ) exception_from_errno (errno );
210
+ bufinfo .len -= ret ;
211
+ bufinfo .buf = (char * )bufinfo .buf + ret ;
212
+ }
213
+ return mp_const_none ;
214
+ }
215
+ STATIC MP_DEFINE_CONST_FUN_OBJ_2 (socket_sendall_obj , socket_sendall );
216
+
201
217
STATIC mp_obj_t socket_fileno (const mp_obj_t arg0 ) {
202
218
socket_obj_t * self = MP_OBJ_TO_PTR (arg0 );
203
219
return mp_obj_new_int (self -> fd );
204
220
}
205
221
STATIC MP_DEFINE_CONST_FUN_OBJ_1 (socket_fileno_obj , socket_fileno );
206
222
223
+ STATIC mp_obj_t socket_makefile (mp_uint_t n_args , const mp_obj_t * args ) {
224
+ (void )n_args ;
225
+ return args [0 ];
226
+ }
227
+ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (socket_makefile_obj , 1 , 3 , socket_makefile );
228
+
207
229
STATIC mp_uint_t socket_stream_read (mp_obj_t self_in , void * buf , mp_uint_t size , int * errcode ) {
208
230
socket_obj_t * socket = self_in ;
209
231
int x = lwip_recvfrom (socket -> fd , buf , size , 0 , NULL , NULL );
@@ -262,14 +284,14 @@ STATIC const mp_map_elem_t socket_locals_dict_table[] = {
262
284
{ MP_OBJ_NEW_QSTR (MP_QSTR_accept ), (mp_obj_t )& socket_accept_obj },
263
285
{ MP_OBJ_NEW_QSTR (MP_QSTR_connect ), (mp_obj_t )& socket_connect_obj },
264
286
{ MP_OBJ_NEW_QSTR (MP_QSTR_send ), (mp_obj_t )& socket_send_obj },
265
- { MP_OBJ_NEW_QSTR (MP_QSTR_sendall ), mp_const_none },
287
+ { MP_OBJ_NEW_QSTR (MP_QSTR_sendall ), ( mp_obj_t ) & socket_sendall_obj },
266
288
{ MP_OBJ_NEW_QSTR (MP_QSTR_recv ), (mp_obj_t )& socket_recv_obj },
267
289
{ MP_OBJ_NEW_QSTR (MP_QSTR_sendto ), mp_const_none },
268
290
{ MP_OBJ_NEW_QSTR (MP_QSTR_recvfrom ), mp_const_none },
269
291
{ MP_OBJ_NEW_QSTR (MP_QSTR_setsockopt ), mp_const_none },
270
292
{ MP_OBJ_NEW_QSTR (MP_QSTR_settimeout ), (mp_obj_t )& socket_settimeout_obj },
271
293
{ MP_OBJ_NEW_QSTR (MP_QSTR_setblocking ), (mp_obj_t )& socket_setblocking_obj },
272
- { MP_OBJ_NEW_QSTR (MP_QSTR_makefile ), mp_const_none },
294
+ { MP_OBJ_NEW_QSTR (MP_QSTR_makefile ), ( mp_obj_t ) & socket_makefile_obj },
273
295
{ MP_OBJ_NEW_QSTR (MP_QSTR_fileno ), (mp_obj_t )& socket_fileno_obj },
274
296
275
297
{ MP_OBJ_NEW_QSTR (MP_QSTR_read ), (mp_obj_t )& mp_stream_read_obj },
0 commit comments