Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Typedefs | Enumerations | Functions

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_socketsol_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...
 

Detailed Description

API to create a communication endpoint using sockets.

Typedef Documentation

typedef struct sol_socket sol_socket

Structure to represent a socket.

Opaque handler for a socket.

See Also
sol_socket_type

Defines specific IP layer related behaviour of a socket instance.

Defines the behaviour of a socket instance.

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.

Enumeration Type Documentation

Represents supported Cipher Suites for use with DTLS.

Enumerator
SOL_SOCKET_DTLS_CIPHER_ECDH_ANON_AES128_CBC_SHA256 
SOL_SOCKET_DTLS_CIPHER_PSK_AES128_CCM8 
SOL_SOCKET_DTLS_CIPHER_ECDHE_ECDSA_AES128_CCM8 

Function Documentation

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

Parameters
sThe value got with sol_socket_ip_new()
addrThe address to associate.
Returns
0 on success, error code (always negative) otherwise.
See Also
sol_socket_join_group()
sol_network_link_addr
Examples:
/src/samples/network/echo-server.c.

Referenced by startup_server().

void sol_socket_del ( struct sol_socket s)

Destroy the socket instance.

Destroy and release all the socket resources

Parameters
sThe value got with sol_socket_ip_new()
See Also
sol_socket_ip_new()
Examples:
/src/samples/network/echo-client.c, and /src/samples/network/echo-server.c.

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.

Parameters
optionsThe socket's options.
Returns
a handle to the socket on success, otherwise NULL is returned.
See Also
sol_socket_del()
sol_socket_options
Examples:
/src/samples/network/echo-client.c, and /src/samples/network/echo-server.c.

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.

Parameters
sThe value got with sol_socket_ip_new()
ifindexThe index of the interface to be used. Interface index is available in sol_network_link.
groupThe address of the group to join.
Returns
0 on success, error code (always negative) otherwise.
See Also
sol_socket_bind()
sol_network_link_addr
sol_network_link
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.

Parameters
sThe value got with sol_socket_ip_new()
bufferthe 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.
cliaddrThe source address of the message.
Returns
The number of bytes read in case of success, error code (always negative) otherwise.
See Also
sol_socket_sendmsg()
sol_buffer_flags
Examples:
/src/samples/network/echo-client.c, and /src/samples/network/echo-server.c.

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.

Parameters
sThe value got with sol_socket_ip_new()
bufferThe data to be transmitted.
cliaddrThe address which the data will be sent.
Returns
0 on success, error code (always negative) otherwise.
See Also
sol_socket_recvmsg()
Examples:
/src/samples/network/echo-client.c, and /src/samples/network/echo-server.c.

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.

Parameters
sThe value got with sol_socket_ip_new()
ontrue 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.
Returns
0 on success, error code (always negative) otherwise.
See Also
sol_socket_ip_new()
Examples:
/src/samples/network/echo-client.c, and /src/samples/network/echo-server.c.

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.

Parameters
sThe value got with sol_socket_ip_new()
ontrue 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.
Returns
0 on success, error code (always negative) otherwise.
See Also
sol_socket_ip_new()
Examples:
/src/samples/network/echo-client.c, and /src/samples/network/echo-server.c.

Referenced by on_can_read(), on_can_write(), and startup_client().