NODERAWSOCKETS: socket fstat and SO_TYPE/SO_LINGER/TCP_MAXSEG options#27306
Open
guybedford wants to merge 1 commit into
Open
NODERAWSOCKETS: socket fstat and SO_TYPE/SO_LINGER/TCP_MAXSEG options#27306guybedford wants to merge 1 commit into
guybedford wants to merge 1 commit into
Conversation
Fills in socket metadata and a few socket options for the node:net backend: * fstat on a socket now reports S_IFSOCK, via a SOCKFS stream_ops.getattr (the core FS.fstat already dispatches to stream_ops.getattr). * getsockopt: SO_TYPE reports the socket type, SO_LINGER round-trips a struct linger, and TCP_MAXSEG reports a default MSS (536 pre-connect, the negotiated loopback value once connected) since node exposes no real MSS. * setsockopt SO_LINGER is honored on close: a zero timeout does an abortive RST close (resetAndDestroy), a positive timeout ends gracefully and forces the connection down once the interval elapses. Adds test/sockets/test_socket_options.c covering fstat/SO_TYPE/SO_LINGER.
This was referenced Jul 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fills in some missing socket metadata and options for the node:net (
-sNODERAWSOCKETS) backend, so more standard socket code behaves as it would on Linux.fstaton a socket now reportsS_IFSOCK(previously it fell through to a generic node), via a SOCKFSstream_ops.getattrthat plugs into theFS.fstatdispatch already present onmain.getsockopt:SO_TYPEreports the type the socket was created with.SO_LINGERround-trips astruct linger.TCP_MAXSEGreports a default MSS. Node exposes no real MSS, so this mirrors Linux: the RFC 879 default (536) before the connection is established, and the (large) loopback-negotiated value once connected.setsockopt SO_LINGERis now honored on close: a zero timeout does an abortive RST close (resetAndDestroy), a positive timeout ends gracefully and forces the connection down once the interval elapses, and otherwise the connection is destroyed as before.Adds
test/sockets/test_socket_options.c(registered astest_noderawsockets_socket_options) covering socketfstat,SO_TYPE,SO_LINGERround-trip, and the pre-connectTCP_MAXSEGdefault.Made with AI assistance under my review