Google Cloud IoT device SDK for embedded C  1.0.2
iotc_bsp_io_net.h
Go to the documentation of this file.
1 /* Copyright 2018-2020 Google LLC
2  *
3  * This is part of the Google Cloud IoT Device SDK for Embedded C.
4  * It is licensed under the BSD 3-Clause license; you may not use this file
5  * except in compliance with the License.
6  *
7  * You may obtain a copy of the License at:
8  * https://opensource.org/licenses/BSD-3-Clause
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __IOTC_BSP_IO_NET_H__
18 #define __IOTC_BSP_IO_NET_H__
19 
131 #include <stddef.h>
132 #include <stdint.h>
133 
134 #ifdef __cplusplus
135 extern "C" {
136 #endif
137 
155 
157 
169 
171 
183 
185 
190 typedef intptr_t iotc_bsp_socket_t;
191 
200 typedef struct iotc_bsp_socket_events_s {
205  uint8_t in_socket_want_read : 1;
208  uint8_t in_socket_want_write : 1;
211  uint8_t in_socket_want_error : 1;
217  uint8_t out_socket_can_read : 1;
220  uint8_t out_socket_can_write : 1;
223  uint8_t out_socket_error : 1;
228 
240  iotc_bsp_socket_t* iotc_socket, const char* host, uint16_t port,
241  iotc_bsp_socket_type_t socket_type);
242 
255  iotc_bsp_socket_events_t* socket_events_array,
256  size_t socket_events_array_size, long timeout_sec);
257 
272  iotc_bsp_socket_t iotc_socket, const char* host, uint16_t port);
273 
289  iotc_bsp_socket_t iotc_socket_nonblocking, int* out_written_count,
290  const uint8_t* buf, size_t count);
291 
302  iotc_bsp_socket_t iotc_socket_nonblocking, int* out_read_count,
303  uint8_t* buf, size_t count);
304 
311  iotc_bsp_socket_t* iotc_socket_nonblocking);
312 
313 #ifdef __cplusplus
314 }
315 #endif
316 
317 #endif /* __IOTC_BSP_IO_NET_H__ */
iotc_bsp_socket_type_e
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.
uint8_t in_socket_want_connect
1 if a connection request is made to a socket, 0 otherwise.
enum iotc_bsp_io_net_state_e iotc_bsp_io_net_state_t
The networking function states.
TCP socket.
uint8_t in_socket_want_write
1 if a read request is made to a socket, 0 otherwise.
uint8_t out_socket_error
1 if an error occurs on the socket, 0 otherwise.
enum iotc_bsp_socket_type_e iotc_bsp_socket_type_t
The socket protocol.
iotc_bsp_socket_t iotc_socket
The platform-specific socket value.
uint8_t out_socket_connect_finished
1 if a connection request succeeded, 0 otherwise.
iotc_bsp_protocol_type_e
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_close_socket(iotc_bsp_socket_t *iotc_socket_nonblocking)
Closes a socket.
uint8_t out_socket_can_read
1 if data can be read from a socket, 0 otherwise.
iotc_bsp_io_net_state_e
UDP socket.
intptr_t iotc_bsp_socket_t
The socket representation.
uint8_t out_socket_can_write
1 if data can be written to a socket, 0 otherwise.
Something went wrong.
enum iotc_bsp_protocol_type_e iotc_bsp_protocol_type_t
The version of the socket protocol.
uint8_t in_socket_want_error
1 if an error request is made to a socket, 0 otherwise.
uint8_t in_socket_want_read
1 if a write request is made to a socket, 0 otherwise.
The networking function succeeded.
struct iotc_bsp_socket_events_s iotc_bsp_socket_events_t
The socket state.
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_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.
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.