Skip to content

Read a request from a socket until all of it is there - #90

Open
amitchone wants to merge 2 commits into
userspace-7-socket-server-user-modefrom
userspace-8-tcp-request-reassembly
Open

amitchone wants to merge 2 commits into
userspace-7-socket-server-user-modefrom
userspace-8-tcp-request-reassembly

Conversation

@amitchone

Copy link
Copy Markdown
Collaborator

No description provided.

@amitchone
amitchone changed the base branch from main to userspace-7-socket-server-user-mode December 2, 2026 16:55
unknown,
};

/// @brief Tells whether a binary request is all there.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly odd wording.

/// @param request What has been received.
/// @param length The number of bytes received.
/// @return What there is of the request.
RequestExtent binaryRequestExtent(const uint8_t *request, size_t length);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getBinaryRequestExtent?

whole,
/// @brief The request breaks off: the rest of it is still to come.
partial,
/// @brief It cannot be told. What there is does not start as a binary request does,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Odd wording.

void adoptPendingSockets();
/// Handler side - reads what is still to come of a request, of which TCP delivers as
/// much at a time as it pleases. Takes the number of bytes that have been read and
/// returns the number there are once the request is whole, or zero if it will not

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...once the request is complete...

/// Handler side - reads what is still to come of a request, of which TCP delivers as
/// much at a time as it pleases. Takes the number of bytes that have been read and
/// returns the number there are once the request is whole, or zero if it will not
/// be: it did not arrive in time, it is too long, or the client has gone.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...gone where?

Comment on lines +155 to +164
switch (skipItem(position, end)) {
case Skip::done:
break;
case Skip::truncated:
return RequestExtent::partial;
default:
return RequestExtent::unknown;
}
if (position == end) {
return RequestExtent::partial;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to understand what this is for...

Comment thread tests/zephyr/ip/src/main.cpp Outdated
Comment on lines +169 to +172
* TCP delivers bytes, not requests: a request may come in as many pieces as the network
* and the client please. The tests below send requests piece by piece, over a socket
* of their own.
*/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting rather tired of seeing TCP packetisation explained over and over again in comments.

Comment thread tests/TestSocketIpClientServer.cpp Outdated
// binary update of the root: the ID 0x300 to 25.0
static const uint8_t updateTo25[] = { (uint8_t)ThingSetBinaryRequestType::update, 0x00, 0xa1, 0x19, 0x03, 0x00, 0xfa, 0x41, 0xc8, 0x00, 0x00 };

/// TCP delivers a request in as many pieces as it pleases. Nothing is done with

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ibid

Comment thread tests/TestSocketIpClientServer.cpp Outdated
Comment on lines +482 to +484
/// Of a request that never arrives in full nothing is handled. The client is
/// told so and the connection is closed, as there is no telling where its next
/// request would start; the server is there for the next client.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As ever, rather florid.

}
}

RequestExtent binaryRequestExtent(const uint8_t *request, size_t length)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the idea that it parses a whole request to check whether it has got the whole request? That seems quite...heavy?

@amitchone
amitchone force-pushed the userspace-8-tcp-request-reassembly branch from 0d9880b to d5a6f27 Compare December 3, 2026 10:05
@amitchone
amitchone force-pushed the userspace-8-tcp-request-reassembly branch from d5a6f27 to 981128a Compare December 3, 2026 11:12
@amitchone
amitchone force-pushed the userspace-8-tcp-request-reassembly branch from 981128a to 0f41408 Compare December 3, 2026 11:47
@amitchone
amitchone force-pushed the userspace-8-tcp-request-reassembly branch from 0f41408 to 4dc41ec Compare December 3, 2026 12:04
@amitchone
amitchone added this pull request to stack #93 December 3, 2026 12:39
@amitchone
amitchone force-pushed the userspace-8-tcp-request-reassembly branch from 4dc41ec to a1fe9ee Compare December 3, 2026 16:06
@amitchone
amitchone force-pushed the userspace-8-tcp-request-reassembly branch from a1fe9ee to 1d50ade Compare December 3, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants