Xively Official / mbed-libxively-5d6fdd4

Dependents:   xively-jumpstart-demo

Embed: (wiki syntax)

« Back to documentation index

comm_layer_t Struct Reference

comm_layer_t Struct Reference

_The communication layer interface_ - contains function pointers, that's what we expose to the layers above and below More...

#include <comm_layer.h>

Data Fields

connection_t *(* open_connection )(const char *address, int32_t port)
 Connect to a given host using it's address and port.
int(* send_data )(connection_t *conn, const char *data, size_t size)
 Send data over the connection.
int(* read_data )(connection_t *conn, char *buffer, size_t buffer_size)
 Read data from a connection.
void(* close_connection )(connection_t *conn)
 Close connection and free all allocated memory (if any)

Detailed Description

_The communication layer interface_ - contains function pointers, that's what we expose to the layers above and below

It is effectively a class that holds declarations of pure virtual functions.

The interface contain methods related to connecting/disconnecting as well as reading/writing data to/from the remote endpoint.

This interface uses abstract `connection_t` class to hold information about the connection in a platform-independent fashion.

Definition at line 37 of file comm_layer.h.


Field Documentation

void( * close_connection)(connection_t *conn)

Close connection and free all allocated memory (if any)

Note:
Some implementations may be stack-based as only limited number of connections is expected in a typical use-case.

Definition at line 65 of file comm_layer.h.

connection_t*( * open_connection)(const char *address, int32_t port)

Connect to a given host using it's address and port.

Note:
It should not reset an existing connection.
Returns:
Pointer to `connection_t` or `0` in case of an error.

Definition at line 44 of file comm_layer.h.

int( * read_data)(connection_t *conn, char *buffer, size_t buffer_size)

Read data from a connection.

Returns:
Number of bytes read or `-1` in case of an error.

Definition at line 58 of file comm_layer.h.

int( * send_data)(connection_t *conn, const char *data, size_t size)

Send data over the connection.

Returns:
Number of bytes sent or `-1` in case of an error.

Definition at line 51 of file comm_layer.h.