← index #15118PR #12549
Related · high · value 2.096
QUERY · ISSUE

network.hostname: max length of hostname

openby massimosalaopened 2024-05-25updated 2024-06-18
enhancement

Checks

  • I agree to follow the MicroPython Code of Conduct to ensure a safe and respectful space for everyone.

  • I've searched for existing issues regarding this feature, and didn't find any.

Description

Form the docs: the max length depends on the port (and its tcp/ip stack).

So, without spelunking into each network low-level libraries or make tests on each specific board, we don't know the limit.

Proposal: calling hostname(None) returns the accepted max length of hostname.

Code Size

No response

Implementation

  • I intend to implement this feature and would submit a Pull Request if desirable.
CANDIDATE · PULL REQUEST

extmod/modnetwork.c: Increase max hostname length to 32.

mergedby jimmoopened 2023-09-29updated 2023-10-04
extmod

See also earlier PRs #12403 and #12404.

This changes from the previous limit of 15 characters. Although DHCP and mDNS allow for up to 63, ESP32 and ESP8266 only allow 32, so this seems like a reasonable limit to enforce across all ports (and avoids wasting the additional memory).

Also clarifies that MICROPY_PY_NETWORK_HOSTNAME_MAX_LEN does not include the null terminator (which was unclear before).

This work was funded through GitHub Sponsors.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied