External interface for socket manipulations used by Kaa transport channel implementations.  
More...
#include "sock.h"
#include "../kaa_error.h"
 
Go to the source code of this file.
 | 
| ext_tcp_utils_function_return_state_t  | ext_tcp_utils_gethostbyaddr (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 hostname of the target host.  More...
  | 
|   | 
| 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.  More...
  | 
|   | 
| 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.  More...
  | 
|   | 
| 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.  More...
  | 
|   | 
| 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.  More...
  | 
|   | 
| 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.  More...
  | 
|   | 
| kaa_error_t  | ext_tcp_utils_tcp_socket_close (kaa_fd_t fd) | 
|   | Closes the given socket.  More...
  | 
|   | 
External interface for socket manipulations used by Kaa transport channel implementations. 
- Author
 - Andriy Panasenko apana.nosp@m.senk.nosp@m.o@cyb.nosp@m.ervi.nosp@m.siont.nosp@m.ech..nosp@m.com 
 
Definition in file ext_tcp_utils.h.
 
      
        
          | #define KAA_TCP_SOCKET_NOT_SET   -1 | 
        
      
 
 
The callback for successful DNS results. See ext_tcp_utils_gethostbyaddr. 
- Parameters
 - 
  
    | [in] | context | Callback's context.  | 
    | [in] | addr | The sockaddr structure of the resolved target host.  | 
    | [in] | addr_size | The size of the sockaddr structure. | 
  
   
- Returns
 - Error code. 
 
Definition at line 69 of file ext_tcp_utils.h.
 
 
      
        
          | typedef kaa_error_t(* on_dns_resolve_failed_fn)(void *context) | 
        
      
 
 
| Enumerator | 
|---|
| KAA_TCP_SOCK_IO_OK  | 
 | 
| KAA_TCP_SOCK_IO_EOF  | 
 | 
| KAA_TCP_SOCK_IO_ERROR  | 
 | 
Definition at line 53 of file ext_tcp_utils.h.
 
 
| Enumerator | 
|---|
| KAA_TCP_SOCK_ERROR  | 
 | 
| KAA_TCP_SOCK_CONNECTING  | 
 | 
| KAA_TCP_SOCK_CONNECTED  | 
 | 
Definition at line 46 of file ext_tcp_utils.h.
 
 
| Enumerator | 
|---|
| RET_STATE_VALUE_ERROR  | 
 | 
| RET_STATE_BUFFER_NOT_ENOUGH  | 
 | 
| RET_STATE_VALUE_READY  | 
 | 
| RET_STATE_VALUE_IN_PROGRESS  | 
 | 
Definition at line 38 of file ext_tcp_utils.h.
 
 
Resolves the hostname of the target host. 
- Parameters
 - 
  
    | [in] | resolve_listener | The listener properties. It is used in case when this function can't resolve a hostname right now.  | 
    | [in] | resolve_props | The target host properties (like hostname and port).  | 
    | [out] | result | The sockaddr_* structure to which the result will be copied.  | 
    | [in,out] | result_size | The total size of the given storage. It will be updated by the actual result size. | 
  
   
- Returns
 - RET_STATE_VALUE_READY - the address was successfully resolved. RET_STATE_VALUE_IN_PROGRESS - the address will be resolved later. See kaa_dns_resolve_listener_t. RET_STATE_VALUE_ERROR - the resolve failed. RET_STATE_BUFFER_NOT_ENOUGH - the given buffer is not enough to store the result. 
 
 
 
Creates a non-blocking TCP socket and connects it to the given target host. 
- Parameters
 - 
  
    | [out] | fd | The valid pointer to a socket descriptor where the result will be saved.  | 
    | [in] | destination | The destination address of the target host.  | 
    | [in] | destination_size | The size of the destination address. | 
  
   
- Returns
 - Error code. 
 
 
 
Sets a new port value to the given sockaddr structure. 
- Parameters
 - 
  
    | [in] | addr | The valid pointer to a sockaddr structure.  | 
    | [in] | port | The new port value in a host byte order. | 
  
   
- Returns
 - Error code. 
 
 
 
Checks the state of the given socket descriptor. 
- Parameters
 - 
  
    | [in] | fd | The socket descriptor which is going to be checked.  | 
    | [in] | destination | The destination address of the target host.  | 
    | [in] | destination_size | The size of the destination address. | 
  
   
- Returns
 - KAA_TCP_SOCK_ERROR - the connection failed. KAA_TCP_SOCK_CONNECTING - the socket is still connecting. KAA_TCP_SOCK_CONNECTED - the socket was successfully connected. 
 
 
 
Closes the given socket. 
- Parameters
 - 
  
    | [in] | fd | The socket descriptor which is going to be closed. | 
  
   
- Returns
 - Error code. 
 
 
 
Reads bytes from the given socket. 
- Parameters
 - 
  
    | [in] | fd | The socket descriptor.  | 
    | [in] | buffer | The buffer to which the read result will be saved.  | 
    | [in] | buffer_size | The maximum number of bytes to be read.  | 
    | [out] | bytes_read | The actual number of bytes which were read from the socket. | 
  
   
- Returns
 - KAA_TCP_SOCK_IO_OK - the buffer was successfully obtained from the socket. KAA_TCP_SOCK_IO_EOF - EOF occurred. KAA_TCP_SOCK_IO_ERROR - the operation failed. 
 
 
 
Writes the buffer into the given socket. 
- Parameters
 - 
  
    | [in] | fd | The socket descriptor.  | 
    | [in] | buffer | The buffer which is going to be written into the socket.  | 
    | [in] | buffer_size | The size of the given buffer.  | 
    | [out] | bytes_written | The actual number of bytes which were successfully written into the socket. | 
  
   
- Returns
 - KAA_TCP_SOCK_IO_OK - the buffer was successfully written into the socket. KAA_TCP_SOCK_IO_ERROR - the operation failed.