Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: net: Add socket service API usage documentation #87110

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jukkar
Copy link
Member

@jukkar jukkar commented Mar 14, 2025

Add information how to use socket service API from application point of view.

Fixes #86982

@jukkar
Copy link
Member Author

jukkar commented Mar 14, 2025

@pdgendt I think I directed you to wrong example of the socket service API. The echo_service sample is probably the simplest app to understand what is going on with the API.

@jukkar jukkar requested a review from kartben March 14, 2025 12:08
Copy link
Collaborator

@pdgendt pdgendt left a comment

Choose a reason for hiding this comment

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

Thanks @jukkar for this, a nice starting point. A few minor remarks, and one "bigger" remark concerning TCP clients.

User specified callback which is called when data is received to the
listening socket.

Application Overview
Copy link
Collaborator

Choose a reason for hiding this comment

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

The overview really only shows a "simple" UDP service, while it is more complex for TCP as it creates new socket file descriptors for connecting clients.
It would be nice to have that distinction in the documentation.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I thought about this, but did not want to write complete application as the echo-service application has that implemented. But we could put something more about TCP and what to do with the accepted socket.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, one thing that tricked me, and would be nice to have documented, is that the accept call can be done in the callback too. This isn't the case in the echo-service sample, where instead a loop is used for a single client.

In most cases, I think, services should serve multiple clients.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, we could enhance the echo-service sample to be a bit more realistic. Patches are welcome to enhance the sample.

@jukkar
Copy link
Member Author

jukkar commented Mar 14, 2025

jukkar added 2 commits March 14, 2025 15:23
Add information how to use socket service API from application
point of view.

Signed-off-by: Jukka Rissanen <[email protected]>
Clarify the documentation in the README.rst file. Also remove the
obsolete comment from main.c as it is no longer correct.

Signed-off-by: Jukka Rissanen <[email protected]>
@jukkar jukkar force-pushed the fix/86982/add-doc-for-socket-services branch from a8d8b2a to aced06a Compare March 14, 2025 13:24
@zephyrbot zephyrbot added area: Samples Samples area: Sockets Networking sockets labels Mar 14, 2025
@jukkar
Copy link
Member Author

jukkar commented Mar 14, 2025

  • Updated according to comments
  • Fixed the documentation in the echo-service sample

@zephyrbot zephyrbot requested a review from nashif March 14, 2025 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add documentation for Socket Services
4 participants