Skip to content

Commit a196468

Browse files
Jared Hancockgreezybacon
authored andcommitted
esp32: Add support for TCP_NODELAY.
This adds support for the TCP_NODELAY socket option for lwIP sockets. Generally, TCP sockets use the Nagle algorithm and will send data when an ACK is received or after all previously-sent data has already been ACKed. If the TCP_NODELAY option is set for a socket, every write to the socket will trigger a packet to be sent. Signed-off-by: Jared Hancock <jared@greezybacon.me>
1 parent b1e9602 commit a196468

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ports/esp32/modsocket.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,16 @@ static mp_obj_t socket_setsockopt(size_t n_args, const mp_obj_t *args) {
528528
}
529529
#endif
530530

531+
// level: IPPROTO_TCP
532+
case TCP_NODELAY: {
533+
int val = mp_obj_get_int(args[3]);
534+
int ret = lwip_setsockopt(self->fd, IPPROTO_TCP, opt, &val, sizeof(int));
535+
if (ret != 0) {
536+
mp_raise_OSError(errno);
537+
}
538+
break;
539+
}
540+
531541
// level: IPPROTO_IP
532542
case IP_ADD_MEMBERSHIP: {
533543
mp_buffer_info_t bufinfo;
@@ -995,6 +1005,7 @@ static const mp_rom_map_elem_t mp_module_socket_globals_table[] = {
9951005
{ MP_ROM_QSTR(MP_QSTR_SO_BROADCAST), MP_ROM_INT(SO_BROADCAST) },
9961006
{ MP_ROM_QSTR(MP_QSTR_SO_BINDTODEVICE), MP_ROM_INT(SO_BINDTODEVICE) },
9971007
{ MP_ROM_QSTR(MP_QSTR_IP_ADD_MEMBERSHIP), MP_ROM_INT(IP_ADD_MEMBERSHIP) },
1008+
{ MP_ROM_QSTR(MP_QSTR_TCP_NODELAY), MP_ROM_INT(TCP_NODELAY) },
9981009
};
9991010

10001011
static MP_DEFINE_CONST_DICT(mp_module_socket_globals, mp_module_socket_globals_table);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy