Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
BSD socket service API

BSD socket service API. More...

Data Structures

struct  net_socket_service_event
 This struct contains information which socket triggered calls to the callback function. More...
 
struct  net_socket_service_desc
 Main structure holding socket service configuration information. More...
 

Macros

#define NET_SOCKET_SERVICE_ASYNC_DEFINE(name, work_q, cb, count)    __z_net_socket_service_define(name, work_q, cb, count, 1)
 Statically define a network socket service.
 
#define NET_SOCKET_SERVICE_ASYNC_DEFINE_STATIC(name, work_q, cb, count)    __z_net_socket_service_define(name, work_q, cb, count, 1, static)
 Statically define a network socket service in a private (static) scope.
 
#define NET_SOCKET_SERVICE_SYNC_DEFINE(name, work_q, cb, count)    __z_net_socket_service_define(name, work_q, cb, count, 0)
 Statically define a network socket service.
 
#define NET_SOCKET_SERVICE_SYNC_DEFINE_STATIC(name, work_q, cb, count)    __z_net_socket_service_define(name, work_q, cb, count, 0, static)
 Statically define a network socket service in a private (static) scope.
 

Typedefs

typedef void(* net_socket_service_cb_t) (const struct net_socket_service_desc *svc, void *user_data)
 Callback used while iterating over socket services.
 

Functions

int net_socket_service_register (const struct net_socket_service_desc *service, struct zsock_pollfd *fds, int len, void *user_data)
 Register pollable sockets.
 
static int net_socket_service_unregister (const struct net_socket_service_desc *service)
 Unregister pollable sockets.
 
void net_socket_service_foreach (net_socket_service_cb_t cb, void *user_data)
 Go through all the socket services and call callback for each service.
 

Detailed Description

BSD socket service API.

Macro Definition Documentation

◆ NET_SOCKET_SERVICE_ASYNC_DEFINE

#define NET_SOCKET_SERVICE_ASYNC_DEFINE (   name,
  work_q,
  cb,
  count 
)     __z_net_socket_service_define(name, work_q, cb, count, 1)

#include <zephyr/net/socket_service.h>

Statically define a network socket service.

The user callback is called asynchronously for this service meaning that the service API will not wait until the user callback returns before continuing with next socket service.

The socket service can be accessed outside the module where it is defined using:

extern struct net_socket_service_desc <name>;
Main structure holding socket service configuration information.
Definition: socket_service.h:60
Note
This macro cannot be used together with a static keyword. If such a use-case is desired, use NET_SOCKET_SERVICE_ASYNC_DEFINE_STATIC instead.
Parameters
nameName of the service.
work_qPointer to workqueue where the work is done. Can be null in which case system workqueue is used.
cbCallback function that is called for socket activity.
countHow many pollable sockets is needed for this service.

◆ NET_SOCKET_SERVICE_ASYNC_DEFINE_STATIC

#define NET_SOCKET_SERVICE_ASYNC_DEFINE_STATIC (   name,
  work_q,
  cb,
  count 
)     __z_net_socket_service_define(name, work_q, cb, count, 1, static)

#include <zephyr/net/socket_service.h>

Statically define a network socket service in a private (static) scope.

The user callback is called asynchronously for this service meaning that the service API will not wait until the user callback returns before continuing with next socket service.

Parameters
nameName of the service.
work_qPointer to workqueue where the work is done. Can be null in which case system workqueue is used.
cbCallback function that is called for socket activity.
countHow many pollable sockets is needed for this service.

◆ NET_SOCKET_SERVICE_SYNC_DEFINE

#define NET_SOCKET_SERVICE_SYNC_DEFINE (   name,
  work_q,
  cb,
  count 
)     __z_net_socket_service_define(name, work_q, cb, count, 0)

#include <zephyr/net/socket_service.h>

Statically define a network socket service.

The user callback is called synchronously for this service meaning that the service API will wait until the user callback returns before continuing with next socket service.

The socket service can be accessed outside the module where it is defined using:

extern struct net_socket_service_desc <name>;
Note
This macro cannot be used together with a static keyword. If such a use-case is desired, use NET_SOCKET_SERVICE_SYNC_DEFINE_STATIC instead.
Parameters
nameName of the service.
work_qPointer to workqueue where the work is done. Can be null in which case system workqueue is used.
cbCallback function that is called for socket activity.
countHow many pollable sockets is needed for this service.

◆ NET_SOCKET_SERVICE_SYNC_DEFINE_STATIC

#define NET_SOCKET_SERVICE_SYNC_DEFINE_STATIC (   name,
  work_q,
  cb,
  count 
)     __z_net_socket_service_define(name, work_q, cb, count, 0, static)

#include <zephyr/net/socket_service.h>

Statically define a network socket service in a private (static) scope.

The user callback is called synchronously for this service meaning that the service API will wait until the user callback returns before continuing with next socket service.

Parameters
nameName of the service.
work_qPointer to workqueue where the work is done. Can be null in which case system workqueue is used.
cbCallback function that is called for socket activity.
countHow many pollable sockets is needed for this service.

Typedef Documentation

◆ net_socket_service_cb_t

net_socket_service_cb_t

#include <zephyr/net/socket_service.h>

Callback used while iterating over socket services.

Parameters
svcPointer to current socket service.
user_dataA valid pointer to user data or NULL

Function Documentation

◆ net_socket_service_foreach()

void net_socket_service_foreach ( net_socket_service_cb_t  cb,
void *  user_data 
)

#include <zephyr/net/socket_service.h>

Go through all the socket services and call callback for each service.

Parameters
cbUser-supplied callback function to call
user_dataUser specified data

◆ net_socket_service_register()

int net_socket_service_register ( const struct net_socket_service_desc service,
struct zsock_pollfd fds,
int  len,
void *  user_data 
)

#include <zephyr/net/socket_service.h>

Register pollable sockets.

Parameters
servicePointer to a service description.
fdsSocket array to poll.
lenLength of the socket array.
user_dataUser specific data.
Return values
0No error
-ENOENTService is not found.
-ENINVALInvalid parameter.

◆ net_socket_service_unregister()

static int net_socket_service_unregister ( const struct net_socket_service_desc service)
inlinestatic

#include <zephyr/net/socket_service.h>

Unregister pollable sockets.

Parameters
servicePointer to a service description.
Return values
0No error
-ENOENTService is not found.
-ENINVALInvalid parameter.