CNDP
22.08.0
|
#include <stdint.h>
#include <stddef.h>
#include <sys/types.h>
Go to the source code of this file.
Data Structures | |
struct | csock_cfg |
Macros | |
#define | __csock_unused __attribute__((__unused__)) |
Typedefs | |
typedef void | csock_t |
typedef void *() | csock_client_fn_t(csock_t *c) |
typedef ssize_t() | csock_write_t(csock_t *c, char *data, size_t len) |
typedef ssize_t() | csock_read_t(csock_t *c, char *data, size_t len) |
typedef int() | csock_close_t(csock_t *c) |
typedef struct csock_cfg | csock_cfg_t |
Enumerations | |
enum | { CSOCK_MAX_HOST_NAME_LENGTH = 128 , CSOCK_MAX_SOCK_INFO_LENGTH = 1024 , DEFAULT_CSOCK_RX_LEN = 4096 , DEFAULT_CSOCK_TX_LEN = 4096 , CSOCK_IS_SERVER = (1 << 0) , CSOCK_IS_CLIENT = (1 << 1) , CSOCK_NON_BLOCKING = (1 << 2) , CSOCK_GROUP_WRITE = (1 << 3) , CSOCK_EOF = (1 << 4) , CSOCK_STDIO_TYPE = (1 << 5) } |
Functions | |
CSOCK_API csock_t * | csock_create (csock_cfg_t *cfg) |
CSOCK_API void | csock_destroy (csock_t *c) |
CSOCK_API int | csock_server_start (csock_t *c) |
CSOCK_API csock_t * | csock_accept (csock_t *s) |
CSOCK_API ssize_t | csock_read (csock_t *c, char *data, size_t len) |
CSOCK_API ssize_t | csock_write (csock_t *c, char *data, size_t len) |
CSOCK_API int | csock_close (csock_t *c) |
CSOCK_API struct sockaddr * | csock_get_peer (csock_t *c) |
CSOCK_API int | csock_eof (csock_t *_c) |
CSOCK_API int | csock_get_fd (csock_t *c) |
CSOCK_API int | csock_set_fd (csock_t *_c, int fd) |
CSOCK_API int | csock_is_closed (csock_t *c) |
CNDP Socket-related utility functions
Routines to support a stdio connection with a TTY or socket connection.
Note: This library is shared between CNDP and non-CNDP applications and can not contain CNDP routines or macros.
Definition in file csock.h.
#define __csock_unused __attribute__((__unused__)) |
typedef void*() csock_client_fn_t(csock_t *c) |
typedef ssize_t() csock_write_t(csock_t *c, char *data, size_t len) |
typedef ssize_t() csock_read_t(csock_t *c, char *data, size_t len) |
typedef int() csock_close_t(csock_t *c) |
typedef struct csock_cfg csock_cfg_t |
Configuration structure
anonymous enum |
CSOCK_API csock_t* csock_create | ( | csock_cfg_t * | cfg | ) |
Create a cloud socket data structure
cfg | Client configuration information. |
CSOCK_API void csock_destroy | ( | csock_t * | c | ) |
Destroy the csock structure and release resources.
c | The csock_t pointer, which is a opaque void pointer |
CSOCK_API int csock_server_start | ( | csock_t * | c | ) |
Start the cloud server connection
c | The csock_t pointer, which is a opaque pointer |
Accept a connection from the remote client.
s | The csock_t pointer, which is the server side data |
CSOCK_API ssize_t csock_read | ( | csock_t * | c, |
char * | data, | ||
size_t | len | ||
) |
Read data from a socket or TTY devices
c | The csock_t pointer, which is a opaque pointer |
data | The data buffer to place the received data. |
len | Size of the data buffer. |
CSOCK_API ssize_t csock_write | ( | csock_t * | c, |
char * | data, | ||
size_t | len | ||
) |
Write data to a socket or TTY devices
c | The csock_t pointer, which is a opaque pointer |
data | The data buffer to get the data to send. |
len | Size of the data in the buffer. |
CSOCK_API int csock_close | ( | csock_t * | c | ) |
Close a socket or tty connection
c | The csock_t pointer, which is a opaque pointer |
CSOCK_API struct sockaddr* csock_get_peer | ( | csock_t * | c | ) |
Get the peer connection address
c | The csock_t pointer, which is a opaque pointer |
CSOCK_API int csock_eof | ( | csock_t * | _c | ) |
Return non-zero if connection had a EOF condition
_c | The csock_t pointer, which is a opaque pointer |
CSOCK_API int csock_get_fd | ( | csock_t * | c | ) |
Return the current FD value for the connection.
c | The csock_t pointer, which is a opaque pointer |
CSOCK_API int csock_set_fd | ( | csock_t * | _c, |
int | fd | ||
) |
Set the connection FD value
_c | The csock_t pointer, which is a opaque pointer |
fd | The FD value for a connection |
CSOCK_API int csock_is_closed | ( | csock_t * | c | ) |
Return non-zero if the connection is closed
c | The csock_t structure pointer |