Soletta™ Framework
|
API to create a communication endpoint using sockets. More...
Data Structures | |
struct | sol_socket |
Structure to represent a socket. More... | |
struct | sol_socket_ip_options |
Defines specific IP layer related behaviour of a socket instance. More... | |
struct | sol_socket_options |
Defines the behaviour of a socket instance. More... | |
struct | sol_socket_type |
Structure to represent a socket class. More... | |
Typedefs | |
typedef struct sol_socket | sol_socket |
Structure to represent a socket. More... | |
typedef struct sol_socket_ip_options | sol_socket_ip_options |
Defines specific IP layer related behaviour of a socket instance. More... | |
typedef struct sol_socket_options | sol_socket_options |
Defines the behaviour of a socket instance. More... | |
typedef struct sol_socket_type | sol_socket_type |
Structure to represent a socket class. More... | |
Enumerations | |
enum | sol_socket_dtls_cipher { SOL_SOCKET_DTLS_CIPHER_ECDH_ANON_AES128_CBC_SHA256, SOL_SOCKET_DTLS_CIPHER_PSK_AES128_CCM8, SOL_SOCKET_DTLS_CIPHER_ECDHE_ECDSA_AES128_CCM8 } |
Represents supported Cipher Suites for use with DTLS. More... | |
Functions | |
int | sol_socket_bind (struct sol_socket *s, const struct sol_network_link_addr *addr) |
Binds the socket to a specific address. More... | |
void | sol_socket_del (struct sol_socket *s) |
Destroy the socket instance. More... | |
struct sol_socket * | sol_socket_ip_new (const struct sol_socket_options *options) |
Creates an endpoint for communication. More... | |
int | sol_socket_join_group (struct sol_socket *s, int ifindex, const struct sol_network_link_addr *group) |
Joins a multicast group. More... | |
ssize_t | sol_socket_recvmsg (struct sol_socket *s, struct sol_buffer *buffer, struct sol_network_link_addr *cliaddr) |
Receive a message from a socket. More... | |
ssize_t | sol_socket_sendmsg (struct sol_socket *s, const struct sol_buffer *buffer, const struct sol_network_link_addr *cliaddr) |
Transmits a message using the socket. More... | |
int | sol_socket_set_read_monitor (struct sol_socket *s, bool on) |
Adds a function to be called when the socket had data to be read. More... | |
int | sol_socket_set_write_monitor (struct sol_socket *s, bool on) |
Adds a function to be called when the socket is able to send data. More... | |
API to create a communication endpoint using sockets.
typedef struct sol_socket sol_socket |
typedef struct sol_socket_ip_options sol_socket_ip_options |
Defines specific IP layer related behaviour of a socket instance.
typedef struct sol_socket_options sol_socket_options |
Defines the behaviour of a socket instance.
typedef struct sol_socket_type sol_socket_type |
Structure to represent a socket class.
This struct contains the necessary information do deal with a socket. This contains the methods necessary to create a new socket type.
int sol_socket_bind | ( | struct sol_socket * | s, |
const struct sol_network_link_addr * | addr | ||
) |
Binds the socket to a specific address.
Assigns the address specified by addr to the socket referred to s
s | The value got with sol_socket_ip_new() |
addr | The address to associate. |
0
on success, error code (always negative) otherwise.Referenced by startup_server().
void sol_socket_del | ( | struct sol_socket * | s | ) |
Destroy the socket instance.
Destroy and release all the socket resources
s | The value got with sol_socket_ip_new() |
Referenced by shutdown_client(), and shutdown_server().
struct sol_socket* sol_socket_ip_new | ( | const struct sol_socket_options * | options | ) |
Creates an endpoint for communication.
This function creates a socket using the system's default implementation.
options | The socket's options. |
NULL
is returned.Referenced by startup_client(), and startup_server().
int sol_socket_join_group | ( | struct sol_socket * | s, |
int | ifindex, | ||
const struct sol_network_link_addr * | group | ||
) |
Joins a multicast group.
Both IPv4 and IPv6 addresses are possible.
s | The value got with sol_socket_ip_new() |
ifindex | The index of the interface to be used. Interface index is available in sol_network_link. |
group | The address of the group to join. |
0
on success, error code (always negative) otherwise.ssize_t sol_socket_recvmsg | ( | struct sol_socket * | s, |
struct sol_buffer * | buffer, | ||
struct sol_network_link_addr * | cliaddr | ||
) |
Receive a message from a socket.
If it's a datagram socket, buf may be NULL
, and in this case the function will only peek the incoming packet queue (not removing data from it), returning the number of bytes needed to store the next datagram and ignoring the cliaddr argument. This way, the user may allocate the exact number of bytes to hold the message contents.
s | The value got with sol_socket_ip_new() |
buffer | the data buffer that will be used to receive the data. If buffer does not has the flags SOL_BUFFER_FLAGS_FIXED_CAPACITY or SOL_BUFFER_FLAGS_MEMORY_NOT_OWNED this functions will allocate/re-allocate. The buffer must be initialized. |
cliaddr | The source address of the message. |
Referenced by on_can_read().
ssize_t sol_socket_sendmsg | ( | struct sol_socket * | s, |
const struct sol_buffer * | buffer, | ||
const struct sol_network_link_addr * | cliaddr | ||
) |
Transmits a message using the socket.
s | The value got with sol_socket_ip_new() |
buffer | The data to be transmitted. |
cliaddr | The address which the data will be sent. |
0
on success, error code (always negative) otherwise.Referenced by on_can_write().
int sol_socket_set_read_monitor | ( | struct sol_socket * | s, |
bool | on | ||
) |
Adds a function to be called when the socket had data to be read.
s | The value got with sol_socket_ip_new() |
on | true to start to monitor the socket. When the socket is available to read the callback set on sol_socket_options will be called, if false it stops monitoring the socket to read. |
0
on success, error code (always negative) otherwise.Referenced by startup_client(), and startup_server().
int sol_socket_set_write_monitor | ( | struct sol_socket * | s, |
bool | on | ||
) |
Adds a function to be called when the socket is able to send data.
s | The value got with sol_socket_ip_new() |
on | true to start to monitor the socket. When the socket is available to write the callback set on sol_socket_options will be called, if false it stops monitoring the socket to write. |
0
on success, error code (always negative) otherwise.Referenced by on_can_read(), on_can_write(), and startup_client().