client-c  0.8.1
ext_tcp_utils.h
Go to the documentation of this file.
1 
25 #ifndef EXT_TCP_UTILS_H_
26 #define EXT_TCP_UTILS_H_
27 
28 #include "sock.h"
29 #include "../kaa_error.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 #define KAA_TCP_SOCKET_NOT_SET -1
36 
37 
38 typedef enum {
44 
45 
46 typedef enum {
51 
52 
53 typedef enum {
58 
59 
69 typedef kaa_error_t (*on_dns_resolve_complete_fn)(void *context
70  , const kaa_sockaddr_t *addr
71  , kaa_socklen_t addr_size);
72 
73 
83 typedef kaa_error_t (*on_dns_resolve_failed_fn)(void *context);
84 
85 
91 typedef struct {
92  void *context;
96 
97 
103 typedef struct {
104  char *hostname;
106  uint16_t port;
108 
109 
131  , const kaa_dns_resolve_info_t *resolve_props
132  , kaa_sockaddr_t *result
133  , kaa_socklen_t *result_size);
134 
135 
145 
146 
158  , const kaa_sockaddr_t *destination
159  , kaa_socklen_t destination_size);
160 
161 
175  , const kaa_sockaddr_t *destination
176  , kaa_socklen_t destination_size);
177 
178 
192  , const char *buffer
193  , size_t buffer_size
194  , size_t *bytes_written);
195 
196 
211  , char *buffer
212  , size_t buffer_size
213  , size_t *bytes_read);
214 
215 
224 
225 #ifdef __cplusplus
226 } /* extern "C" */
227 #endif
228 
229 
230 #endif /* EXT_TCP_UTILS_H_ */
ext_tcp_socket_io_errors_t ext_tcp_utils_tcp_socket_read(kaa_fd_t fd, char *buffer, size_t buffer_size, size_t *bytes_read)
Reads bytes from the given socket.
ext_tcp_socket_io_errors_t ext_tcp_utils_tcp_socket_write(kaa_fd_t fd, const char *buffer, size_t buffer_size, size_t *bytes_written)
Writes the buffer into the given socket.
ext_tcp_utils_function_return_state_t ext_tcp_utils_getaddrbyhost(kaa_dns_resolve_listener_t *resolve_listener, const kaa_dns_resolve_info_t *resolve_props, kaa_sockaddr_t *result, kaa_socklen_t *result_size)
Resolves the address of the target host.
on_dns_resolve_failed_fn on_resolve_failed
Definition: ext_tcp_utils.h:94
ext_tcp_socket_io_errors_t
Definition: ext_tcp_utils.h:53
kaa_error_t
Definition: kaa_error.h:31
The target host information which is used for the DNS resolve needs.
socklen_t kaa_socklen_t
Definition: cc32xx_sock.h:78
on_dns_resolve_complete_fn on_host_resolved
Definition: ext_tcp_utils.h:93
kaa_error_t(* on_dns_resolve_failed_fn)(void *context)
The callback for negative host resolve results.
Definition: ext_tcp_utils.h:83
kaa_error_t ext_tcp_utils_set_sockaddr_port(kaa_sockaddr_t *addr, uint16_t port)
Sets a new port value to the given sockaddr structure.
ext_tcp_socket_state_t ext_tcp_utils_tcp_socket_check(kaa_fd_t fd, const kaa_sockaddr_t *destination, kaa_socklen_t destination_size)
Checks the state of the given socket descriptor.
kaa_error_t(* on_dns_resolve_complete_fn)(void *context, const kaa_sockaddr_t *addr, kaa_socklen_t addr_size)
The callback for successful DNS results. See ext_tcp_utils_getaddrbyhost.
Definition: ext_tcp_utils.h:69
Interface for the deferred DNS results.
Definition: ext_tcp_utils.h:91
ext_tcp_utils_function_return_state_t
Definition: ext_tcp_utils.h:38
ext_tcp_socket_state_t
Definition: ext_tcp_utils.h:46
int kaa_fd_t
Definition: cc32xx_sock.h:74
kaa_error_t ext_tcp_utils_open_tcp_socket(kaa_fd_t *fd, const kaa_sockaddr_t *destination, kaa_socklen_t destination_size)
Creates a non-blocking TCP socket and connects it to the given target host.
struct sockaddr kaa_sockaddr_t
Definition: cc32xx_sock.h:76
kaa_error_t ext_tcp_utils_tcp_socket_close(kaa_fd_t fd)
Closes the given socket.