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 Fields
sol_socket_type Struct Reference

Structure to represent a socket class. More...

#include <sol-socket.h>

Data Fields

uint16_t api_version
 must match SOL_SOCKET_TYPE_API_VERSION at runtime. More...
 
int(* bind )(struct sol_socket *s, const struct sol_network_link_addr *addr)
 Function to be called to bind the socket to a network address. More...
 
void(* del )(struct sol_socket *s)
 Function to be called when the socket is deleted. More...
 
int(* join_group )(struct sol_socket *s, int ifindex, const struct sol_network_link_addr *group)
 Function to be called to join a multicast group. More...
 
ssize_t(* recvmsg )(struct sol_socket *s, struct sol_buffer *buffer, struct sol_network_link_addr *cliaddr)
 Function to be called to read data from socket. More...
 
ssize_t(* sendmsg )(struct sol_socket *s, const struct sol_buffer *buffer, const struct sol_network_link_addr *cliaddr)
 Function to be called to write data in the socket. More...
 
int(* set_read_monitor )(struct sol_socket *s, bool on)
 Starts or stops monitoring the socket for reading. More...
 
int(* set_write_monitor )(struct sol_socket *s, bool on)
 Starts or stops monitoring the socket for writing. More...
 

Detailed Description

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.

Field Documentation

uint16_t sol_socket_type::api_version

must match SOL_SOCKET_TYPE_API_VERSION at runtime.

int(* sol_socket_type::bind)(struct sol_socket *s, const struct sol_network_link_addr *addr)

Function to be called to bind the socket to a network address.

  • s the socket pointer (this)
  • addr the address to bind.
  • returns 0 in success, otherwise a negative (errno) value is returned.
void(* sol_socket_type::del)(struct sol_socket *s)

Function to be called when the socket is deleted.

  • s the socket pointer (this)
int(* sol_socket_type::join_group)(struct sol_socket *s, int ifindex, const struct sol_network_link_addr *group)

Function to be called to join a multicast group.

Both IPv4 and IPv6 addresses are possible.

  • s the socket pointer (this)
  • 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.
  • returns 0 in success, otherwise a negative (errno) value is returned.
ssize_t(* sol_socket_type::recvmsg)(struct sol_socket *s, struct sol_buffer *buffer, struct sol_network_link_addr *cliaddr)

Function to be called to read data from socket.

  • s the socket pointer (this)
  • 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 necessary memory. The buffer must be initialized.
  • cliaddr the source address of the message
  • returns the number of bytes received in success, otherwise a negative (errno) value is returned.
See Also
sol_buffer_flags
ssize_t(* sol_socket_type::sendmsg)(struct sol_socket *s, const struct sol_buffer *buffer, const struct sol_network_link_addr *cliaddr)

Function to be called to write data in the socket.

  • s the socket pointer (this)
  • buffer the data to be transmitted
  • cliaddr the address which the data will be sent
  • returns the number of bytes written in success, otherwise a negative (errno) value is returned.
int(* sol_socket_type::set_read_monitor)(struct sol_socket *s, bool on)

Starts or stops monitoring the socket for reading.

  • s the socket pointer (this)
  • on true to be called when there is data to be read or false otherwise.
  • returns 0 in success, otherwise a negative (errno) value is returned.
int(* sol_socket_type::set_write_monitor)(struct sol_socket *s, bool on)

Starts or stops monitoring the socket for writing.

  • s the socket pointer (this)
  • on true to be called when there is possible to write or false otherwise.
  • returns 0 in success, otherwise a negative (errno) value is returned.

The documentation for this struct was generated from the following file: