Socket

bool kprv_socket_server_setup(socket_conn *conn, uint16_t port, uint8_t num_connections)

Performs the low level init and setup of the server side tcp socket.

Return
bool true if successful, otherwise false
Parameters
  • conn: pointer to socket_conn where connection info will be stored
  • port: port to listen for connections on
  • num_connections: max number of connections to listen for

bool kprv_socket_server_accept(const socket_conn *server_conn, socket_conn *client_conn)

Attempts to accept a new socket connection - currently blocking.

Return
bool true if successful, otherwise false
Parameters
  • server_conn: pointer to socket_conn with listening socket info
  • client_conn: pointer to socket_conn where accepted connection info is stored

bool kprv_socket_client_connect(socket_conn *conn, uint16_t port)

Attempts to open a socket connection.

Return
bool true if successful, otherwise false
Parameters
  • conn: pointer to socket_conn where connection info will be stored
  • port: port to connect on

bool kprv_socket_close(socket_conn *conn)

Performs low level shutdown and closure of connection.

Return
bool true if successful, otherwise false
Parameters

bool kprv_socket_send(const socket_conn *conn, const uint8_t *data_buffer, uint32_t data_length)

Performs socket send.

Return
bool true if successful, otherwise false
Parameters
  • conn: pointer to socket_conn
  • data_buffer: data to send
  • data_length: length of data to send

bool kprv_socket_recv(const socket_conn *conn, uint8_t *data_buffer, uint32_t data_length, uint32_t *length_read)

Performs socket receive.

Return
bool true if successful, otherwise false
Parameters
  • conn: pointer to socket_conn
  • data_buffer: buffer to write received data to
  • data_length: max size of data buffer
  • length_read: number of bytes actually received

struct socket_conn
#include <socket.h>

PubSub connection structure.