Kaa client C SDK
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Typedefs | Enumerations | Functions
kaa_tcp_channel.h File Reference
#include "kaa_error.h"
#include "platform/ext_transport_channel.h"
#include <platform/defaults.h>
#include "platform/ext_tcp_utils.h"

Go to the source code of this file.

Typedefs

typedef kaa_error_t(* on_kaa_tcp_channel_event_fn )(void *context, kaa_tcp_channel_event_t event_type, kaa_fd_t fd)
 Notifies about the current channel's state. More...
 

Enumerations

enum  fd_event_t { FD_READ, FD_WRITE, FD_EXCEPTION }
 
enum  kaa_tcp_channel_event_t { SOCKET_CONNECTED, SOCKET_DISCONNECTED, SOCKET_CONNECTION_ERROR }
 

Functions

kaa_error_t kaa_tcp_channel_create (kaa_transport_channel_interface_t *self, kaa_logger_t *logger, kaa_extension_id *supported_services, size_t supported_service_count)
 Creates a Kaa TCP channel instance. More...
 
kaa_error_t kaa_tcp_channel_get_descriptor (kaa_transport_channel_interface_t *self, kaa_fd_t *fd_p)
 Retrieves the socket descriptor from the given channel instance. More...
 
bool kaa_tcp_channel_is_ready (kaa_transport_channel_interface_t *self, fd_event_t event_type)
 Checks whether the given channel instance is ready to handle the specified event. More...
 
kaa_error_t kaa_tcp_channel_process_event (kaa_transport_channel_interface_t *self, fd_event_t event_type)
 Notifies the channel instance about the I/O event. More...
 
kaa_error_t kaa_tcp_channel_get_max_timeout (kaa_transport_channel_interface_t *self, uint16_t *max_timeout)
 Retrieves the maximum timeout for the multiplexing I/O like select/poll. More...
 
kaa_error_t kaa_tcp_channel_check_keepalive (kaa_transport_channel_interface_t *self)
 Checks whether a keepalive timeout occurred. More...
 
kaa_error_t kaa_tcp_channel_set_socket_events_callback (kaa_transport_channel_interface_t *self, on_kaa_tcp_channel_event_fn callback, void *context)
 Sets the callback for the current channel connection state. More...
 
kaa_error_t kaa_tcp_channel_disconnect (kaa_transport_channel_interface_t *self)
 Disconnects the current channel. More...
 

Typedef Documentation

typedef kaa_error_t(* on_kaa_tcp_channel_event_fn)(void *context, kaa_tcp_channel_event_t event_type, kaa_fd_t fd)

Notifies about the current channel's state.

Used by kaa_tcp_channel_set_socket_events_callback .

Parameters
[in]contextCallback's context
[in]event_typeThe current state of the channel (SOCKET_CONNECTED, SOCKET_DISCONNECTED or SOCKET_CONNECTION_ERROR).
[in]fdThe socket descriptor to which the event occurred.
Returns
Error code

Enumeration Type Documentation

enum fd_event_t
Enumerator
FD_READ 
FD_WRITE 
FD_EXCEPTION 
Enumerator
SOCKET_CONNECTED 
SOCKET_DISCONNECTED 
SOCKET_CONNECTION_ERROR 

Function Documentation

kaa_error_t kaa_tcp_channel_check_keepalive ( kaa_transport_channel_interface_t self)

Checks whether a keepalive timeout occurred.

If so, sends a keepalive message to the server.

Should be called if the multiplexing I/O (like select/poll) time limit expires.

Parameters
[in]selfThe channel instance.
Returns
Error code.
kaa_error_t kaa_tcp_channel_create ( kaa_transport_channel_interface_t self,
kaa_logger_t logger,
kaa_extension_id supported_services,
size_t  supported_service_count 
)

Creates a Kaa TCP channel instance.

Parameters
[in]selfThe pointer to the channel instance.
[in]loggerThe pointer to the Kaa logger instance.
[in]supported_servicesA list of supported services for this channel.
[in]supported_service_countThe number of services in the list.
Returns
Error code
kaa_error_t kaa_tcp_channel_disconnect ( kaa_transport_channel_interface_t self)

Disconnects the current channel.

Parameters
[in]selfThe channel instance.
Returns
Error code
kaa_error_t kaa_tcp_channel_get_descriptor ( kaa_transport_channel_interface_t self,
kaa_fd_t fd_p 
)

Retrieves the socket descriptor from the given channel instance.

Parameters
[in]selfThe channel instance.
[out]fd_pThe socket descriptor or KAA_TCP_SOCKET_NOT_SET if there is no open descriptor.
Returns
Error code.
kaa_error_t kaa_tcp_channel_get_max_timeout ( kaa_transport_channel_interface_t self,
uint16_t *  max_timeout 
)

Retrieves the maximum timeout for the multiplexing I/O like select/poll.

Used for kaa_tcp_channel_check_keepalive needs.

Parameters
[in]selfThe channel instance.
[out]max_timeoutThe maximum timeout value (in seconds), 0 - indicates that timeout is not used by this channel.
Returns
Error code.
bool kaa_tcp_channel_is_ready ( kaa_transport_channel_interface_t self,
fd_event_t  event_type 
)

Checks whether the given channel instance is ready to handle the specified event.

Parameters
[in]selfThe channel instance.
[in]event_typeThe event type: FD_READ, FD_WRITE, FD_EXCEPTION.
Returns
true - if the channel is ready to handle the specified event, false - otherwise.
kaa_error_t kaa_tcp_channel_process_event ( kaa_transport_channel_interface_t self,
fd_event_t  event_type 
)

Notifies the channel instance about the I/O event.

Parameters
[in]selfThe channel instance.
[in]event_typeThe event type: FD_READ, FD_WRITE, FD_EXEPTION.
Returns
Error code.
kaa_error_t kaa_tcp_channel_set_socket_events_callback ( kaa_transport_channel_interface_t self,
on_kaa_tcp_channel_event_fn  callback,
void *  context 
)

Sets the callback for the current channel connection state.

See on_kaa_tcp_channel_event_fn .

Parameters
[in]selfThe channel instance.
[in]callbackThe connection event callback.
[in]contextThe callback context.
Returns
Error code.