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 storedport
: port to listen for connections onnum_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 infoclient_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 storedport
: 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
conn
: pointer to socket_conn
-
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_conndata_buffer
: data to senddata_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_conndata_buffer
: buffer to write received data todata_length
: max size of data bufferlength_read
: number of bytes actually received
-
struct
socket_conn
¶ - #include <socket.h>
PubSub connection structure.