Lines Matching full:socket
29 config option and implements the following operations: ``socket()``, ``close()``,
61 sample applications to learn how to create a simple server or client BSD socket based
69 Zephyr provides an extension of standard POSIX socket API, allowing to create
73 protocols with standard socket calls. See :c:enum:`net_ip_protocol_secure` type
90 later on to reference the credential during secure socket configuration with
91 socket options.
112 Secure Socket Creation
115 A secure socket can be created by specifying secure protocol type, for instance:
119 sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TLS_1_2);
121 Once created, it can be configured with socket options. For instance, the
139 Once configured, socket can be used just like a regular TCP socket.
148 Secure sockets offer the following options for socket management:
152 Socket offloading
155 Zephyr allows to register custom socket implementations (called offloaded
157 external IP stack and expose socket-like API.
159 Socket offloading can be enabled with :kconfig:option:`CONFIG_NET_SOCKETS_OFFLOAD`
160 option. A network driver that wants to register a new socket implementation
165 An arbitrary name for the socket implementation.
168 Socket implementation's priority. The higher the priority, the earlier this
169 particular implementation will be processed when creating a new socket.
173 Socket family implemented by the offloaded socket. ``AF_UNSPEC`` indicates
177 A filtering function, used to verify whether a particular socket family,
178 type and protocol are supported by the offloaded socket implementation.
181 A function compatible with :c:func:`socket` API, used to create an
182 offloaded socket.
184 Every offloaded socket implementation should also implement a set of socket
187 The function registered for socket creation should allocate a new file
189 specific to the creation of a particular offloaded socket implementation,
191 if the offloaded socket was created successfully, the file descriptor should
194 :c:struct:`socket_op_vtable` structure implementing socket APIs for an
195 offloaded socket along with an optional socket context data pointer.
199 function. The function registers the function used to create an offloaded socket
203 Offloaded socket creation
206 When application creates a new socket with :c:func:`socket` function, the
207 network stack iterates over all registered socket implementations (native and
208 offloaded). Higher priority socket implementations are processed first.
209 For each registered socket implementation, an address family is verified, and if
210 it matches (or the socket was registered as ``AF_UNSPEC``), the corresponding
211 ``_is_supported`` function is called to verify the remaining socket parameters.
212 The first implementation that fulfills the socket requirements (i. e.
213 ``_is_supported`` returns true) will create a new socket with its ``_handler``
216 The above indicates the importance of the socket priority. If multiple socket
217 implementations support the same set of socket family/type/protocol, the first
218 implementation processed by the system will create a socket. Therefore it's
222 The socket priority for native socket implementation is configured with Kconfig.
231 As the :c:func:`socket` function does not allow to specify which network
232 interface should be used by a socket, it's not possible to choose a specific
233 implementation in case multiple offloaded socket implementations, supporting the
237 To address this problem, a special socket implementation (called socket
239 socket creation for until the first operation on a socket is performed. This
240 leaves an opening to use ``SO_BINDTODEVICE`` socket option, to bind a socket to
241 a particular network interface (and thus offloaded socket implementation).
242 The socket dispatcher can be enabled with :kconfig:option:`CONFIG_NET_SOCKETS_OFFLOAD_DISPATCHER`
250 /* A "dispatcher" socket is created */
251 sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
257 /* The socket is "dispatched" to a particular network interface
263 ``TLS_NATIVE`` socket option can be used to indicate that a native TLS socket
264 should be created. The underlying socket can then be bound to a particular
269 /* A "dispatcher" socket is created */
270 sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TLS_1_2);
274 /* The socket is "dispatched" to a native TLS socket implmeentation.
275 * The underlying socket is a "dispatcher" socket now.
283 /* The underlying socket is "dispatched" to a particular network interface
288 In case no ``SO_BINDTODEVICE`` socket option is used on a socket, the socket
290 first socket API call.