|
Google Cloud IoT device SDK for embedded C
1.0.2
|
Go to the source code of this file.
Data Structures | |
| struct | iotc_bsp_socket_events_s |
Typedefs | |
| typedef enum iotc_bsp_io_net_state_e | iotc_bsp_io_net_state_t |
| typedef enum iotc_bsp_socket_type_e | iotc_bsp_socket_type_t |
| typedef enum iotc_bsp_protocol_type_e | iotc_bsp_protocol_type_t |
| typedef intptr_t | iotc_bsp_socket_t |
| typedef struct iotc_bsp_socket_events_s | iotc_bsp_socket_events_t |
Enumerations | |
| enum | iotc_bsp_io_net_state_e { IOTC_BSP_IO_NET_STATE_OK = 0, IOTC_BSP_IO_NET_STATE_ERROR = 1, IOTC_BSP_IO_NET_STATE_BUSY = 2, IOTC_BSP_IO_NET_STATE_CONNECTION_RESET = 3, IOTC_BSP_IO_NET_STATE_TIMEOUT = 4 } |
| enum | iotc_bsp_socket_type_e { SOCKET_STREAM = 1, SOCKET_DGRAM = 2 } |
| enum | iotc_bsp_protocol_type_e { PROTOCOL_IPV4 = 2, PROTOCOL_IPV6 = 10 } |
Functions | |
| iotc_bsp_io_net_state_t | iotc_bsp_io_net_socket_connect (iotc_bsp_socket_t *iotc_socket, const char *host, uint16_t port, iotc_bsp_socket_type_t socket_type) |
| iotc_bsp_io_net_state_t | iotc_bsp_io_net_select (iotc_bsp_socket_events_t *socket_events_array, size_t socket_events_array_size, long timeout_sec) |
| iotc_bsp_io_net_state_t | iotc_bsp_io_net_connection_check (iotc_bsp_socket_t iotc_socket, const char *host, uint16_t port) |
| iotc_bsp_io_net_state_t | iotc_bsp_io_net_write (iotc_bsp_socket_t iotc_socket_nonblocking, int *out_written_count, const uint8_t *buf, size_t count) |
| iotc_bsp_io_net_state_t | iotc_bsp_io_net_read (iotc_bsp_socket_t iotc_socket_nonblocking, int *out_read_count, uint8_t *buf, size_t count) |
| iotc_bsp_io_net_state_t | iotc_bsp_io_net_close_socket (iotc_bsp_socket_t *iotc_socket_nonblocking) |
Creates and manages asynchronous sockets in the device's native socket library.
A typical networking workflow:
Definition in file iotc_bsp_io_net.h.
The version of the socket protocol.
The socket state.
The socket representation.
Definition at line 190 of file iotc_bsp_io_net.h.
The socket protocol.
Definition at line 144 of file iotc_bsp_io_net.h.
| Enumerator | |
|---|---|
| PROTOCOL_IPV4 | IPv4. |
| PROTOCOL_IPV6 | IPv6. |
Definition at line 178 of file iotc_bsp_io_net.h.
| Enumerator | |
|---|---|
| SOCKET_STREAM | TCP socket. |
| SOCKET_DGRAM | UDP socket. |
Definition at line 164 of file iotc_bsp_io_net.h.
| iotc_bsp_io_net_state_t iotc_bsp_io_net_close_socket | ( | iotc_bsp_socket_t * | iotc_socket_nonblocking | ) |
Closes a socket.
| [in] | iotc_socket_nonblocking | The socket to close. |
| iotc_bsp_io_net_state_t iotc_bsp_io_net_connection_check | ( | iotc_bsp_socket_t | iotc_socket, |
| const char * | host, | ||
| uint16_t | port | ||
| ) |
Checks a socket connection status.
The SDK calls the function after iotc_bsp_io_net_connect() to complete the socket connection. If the socket is connected, the SDK initiates a TLS handshake.
| [in] | iotc_socket | The socket on which check the connection. |
| [in] | host | The null-terminated IP or fully-qualified domain name of the host at which to connect. |
| [in] | port | The port number of the endpoint. |
| iotc_bsp_io_net_state_t iotc_bsp_io_net_read | ( | iotc_bsp_socket_t | iotc_socket_nonblocking, |
| int * | out_read_count, | ||
| uint8_t * | buf, | ||
| size_t | count | ||
| ) |
Reads data from a socket.
| [in] | iotc_socket_nonblocking | The socket from which to read data. |
| [out] | out_read_count | The number of bytes read from the socket. |
| [out] | buf | A pointer to a buffer with the data read from the socket. |
| [in] | count | The size, in bytes, of the buffer to which the buf parameter points. |
| iotc_bsp_io_net_state_t iotc_bsp_io_net_select | ( | iotc_bsp_socket_events_t * | socket_events_array, |
| size_t | socket_events_array_size, | ||
| long | timeout_sec | ||
| ) |
Checks a socket for scheduled read or write operations.
| [in] | socket_events_array | An array of socket events. |
| [in] | socket_events_array_size | The number of elements in socket_events_array. |
| [in] | timeout_sec | The number of seconds before timing out. |
| iotc_bsp_io_net_state_t iotc_bsp_io_net_socket_connect | ( | iotc_bsp_socket_t * | iotc_socket, |
| const char * | host, | ||
| uint16_t | port, | ||
| iotc_bsp_socket_type_t | socket_type | ||
| ) |
Creates a socket and connects it to an endpoint.
| [out] | iotc_socket | The platform-specific socket representation This value is passed to all further BSP networking calls. |
| [in] | host | The null-terminated IP or fully-qualified domain name of the host at which to connect. |
| [in] | port | The port number of the endpoint. |
| [in] | socket_type | The socket protocol. |
| iotc_bsp_io_net_state_t iotc_bsp_io_net_write | ( | iotc_bsp_socket_t | iotc_socket_nonblocking, |
| int * | out_written_count, | ||
| const uint8_t * | buf, | ||
| size_t | count | ||
| ) |
Writes data to a socket.
This function writes data in chunks, so the SDK calls it repeatedly until all chunks are written to the buffer. The SDK writes a new chunk to the socket on each event loop tick.
| [in] | iotc_socket_nonblocking | The socket on which to send data. |
| [out] | out_written_count | The number of bytes written to the socket. If the value is negative, the connection is closed. |
| [in] | buf | A pointer to a buffer with the data. |
| [in] | count | The size, in bytes, of the buffer to which the buf parameter points. |