client-c  0.6.3
kaa_tcp_channel.h File Reference
+ Include dependency graph for kaa_tcp_channel.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. Used by kaa_tcp_channel_set_socket_events_callback . 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_service_t *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. Used for kaa_tcp_channel_check_keepalive needs. More...
 
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. 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_set_keepalive_timeout (kaa_transport_channel_interface_t *self, uint16_t keepalive)
 Sets a keepalive timeout for the current channel. 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

Definition at line 57 of file kaa_tcp_channel.h.

Enumeration Type Documentation

enum fd_event_t
Enumerator
FD_READ 
FD_WRITE 
FD_EXCEPTION 

Definition at line 31 of file kaa_tcp_channel.h.

Enumerator
SOCKET_CONNECTED 
SOCKET_DISCONNECTED 
SOCKET_CONNECTION_ERROR 

Definition at line 38 of file kaa_tcp_channel.h.

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]channelThe channel instance.
Returns
Error code.
kaa_error_t kaa_tcp_channel_create ( kaa_transport_channel_interface_t self,
kaa_logger_t logger,
kaa_service_t supported_services,
size_t  supported_service_count 
)

Creates a Kaa TCP channel instance.

Parameters
[in]channelThe pointer to the channel instance. t*
[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]channelThe 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]channelThe 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]channelThe 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]channelThe 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]channelThe channel instance.
[in]event_typeThe event type: FD_READ, FD_WRITE, FD_EXEPTION.
Returns
Error code.
kaa_error_t kaa_tcp_channel_set_keepalive_timeout ( kaa_transport_channel_interface_t self,
uint16_t  keepalive 
)

Sets a keepalive timeout for the current channel.

Parameters
[in]channelThe channel instance.
[in]keepaliveThe keepalive timeout (in seconds). 0 - indicates that a keepalive is not used.
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 kaa_tcp_channel_event_fn .

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