Skip to content

Commit 1564e20

Browse files
jukkarnashif
authored andcommitted
doc: net: Minor fixes to BSD socket documentation
Some clarifications to BSD socket descriptions. Also added rendering hints for some strings. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent 2c3445b commit 1564e20

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

doc/reference/networking/sockets.rst

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@ and port existing simple networking applications to Zephyr.
1717
Here are the key requirements and concepts which governed BSD Sockets
1818
compatible API implementation for Zephyr:
1919

20-
* Should have minimal overhead, similar to the requirement for other
20+
* Has minimal overhead, similar to the requirement for other
2121
Zephyr subsystems.
22-
* Should be implemented on top of
23-
:ref:`native networking API <networking_api_usage>` to keep modular
24-
design.
25-
* Should be namespaced by default, to avoid name conflicts with well-known
22+
* Is namespaced by default, to avoid name conflicts with well-known
2623
names like ``close()``, which may be part of libc or other POSIX
27-
compatibility libraries. If enabled, should also expose native POSIX
28-
names.
24+
compatibility libraries.
25+
If enabled by :option:`CONFIG_NET_SOCKETS_POSIX_NAMES`, it will also
26+
expose native POSIX names.
2927

3028
BSD Sockets compatible API is enabled using :option:`CONFIG_NET_SOCKETS`
3129
config option and implements the following operations: ``socket()``, ``close()``,
@@ -47,8 +45,8 @@ Another entailment of the design requirements above is that the Zephyr
4745
API aggressively employs the short-read/short-write property of the POSIX API
4846
whenever possible (to minimize complexity and overheads). POSIX allows
4947
for calls like ``recv()`` and ``send()`` to actually process (receive
50-
or send) less data than requested by the user (on SOCK_STREAM type sockets).
51-
For example, a call ``recv(sock, 1000, 0)`` may return 100,
48+
or send) less data than requested by the user (on ``SOCK_STREAM`` type
49+
sockets). For example, a call ``recv(sock, 1000, 0)`` may return 100,
5250
meaning that only 100 bytes were read (short read), and the application
5351
needs to retry call(s) to receive the remaining 900 bytes.
5452

@@ -68,12 +66,12 @@ Zephyr provides an extension of standard POSIX socket API, allowing to create
6866
and configure sockets with TLS protocol types, facilitating secure
6967
communication. Secure functions for the implementation are provided by
7068
mbedTLS library. Secure sockets implementation allows use of both TLS and DTLS
71-
protocols with standard socket calls. See :c:type:`net_ip_protocol_secure` for
72-
supported secure protocol versions.
69+
protocols with standard socket calls. See :c:type:`net_ip_protocol_secure` type
70+
for supported secure protocol versions.
7371

74-
To enable secure sockets, set the
75-
:option:`CONFIG_NET_SOCKETS_SOCKOPT_TLS`
76-
option. To enable DTLS support, use :option:`CONFIG_NET_SOCKETS_ENABLE_DTLS`.
72+
To enable secure sockets, set the :option:`CONFIG_NET_SOCKETS_SOCKOPT_TLS`
73+
option. To enable DTLS support, use :option:`CONFIG_NET_SOCKETS_ENABLE_DTLS`
74+
option.
7775

7876
TLS credentials subsystem
7977
=========================
@@ -120,7 +118,7 @@ CA certificate and hostname can be set:
120118
.. code-block:: c
121119
122120
sec_tag_t sec_tag_opt[] = {
123-
CA_CERTIFICATE_TAG,
121+
CA_CERTIFICATE_TAG,
124122
};
125123
126124
ret = setsockopt(sock, SOL_TLS, TLS_SEC_TAG_LIST,
@@ -130,12 +128,13 @@ CA certificate and hostname can be set:
130128
131129
char host[] = "google.com";
132130
133-
ret = setsockopt(sock, SOL_TLS, TLS_HOSTNAME, host, sizeof(host));
131+
ret = setsockopt(sock, SOL_TLS, TLS_HOSTNAME, host, sizeof(host) - 1);
134132
135133
Once configured, socket can be used just like a regular TCP socket.
136134

137135
Several samples in Zephyr use secure sockets for communication. For a sample use
138-
see e.g. :ref:`sockets-echo-server-sample` or :ref:`sockets-http-get`.
136+
see e.g. :ref:`echo-server sample application <sockets-echo-server-sample>` or
137+
:ref:`HTTP GET sample application <sockets-http-get>`.
139138

140139
Secure Sockets options
141140
======================

0 commit comments

Comments
 (0)