21#include <citrusleaf/cf_clock.h>
28#include <netinet/in.h>
29#include <sys/socket.h>
32#define as_socket_fd int
33#define as_socket_data_t void
34#define as_socket_size_t size_t
35#define AS_CONNECTING EINPROGRESS
36#define AS_WOULDBLOCK EWOULDBLOCK
37#define as_close(_fd) close((_fd))
38#define as_last_error() errno
41#define SOL_TCP IPPROTO_TCP
45#define as_socket_fd SOCKET
46#define AS_CONNECTING WSAEWOULDBLOCK
47#define AS_WOULDBLOCK WSAEWOULDBLOCK
48#define SHUT_RDWR SD_BOTH
49#define as_close(_fd) closesocket((_fd))
50#define as_last_error() WSAGetLastError()
64typedef struct as_tls_context_s {
79typedef struct as_socket_s {
87 struct as_conn_pool_s*
pool;
199 return max_socket_idle_ns == 0 || (cf_getns() - last_used) <= max_socket_idle_ns;
209 return (cf_getns() - last_used) <= max_socket_idle_ns;
228static inline uint64_t
231 return (timeout_ms && timeout_ms <= INT32_MAX)? cf_getms() + timeout_ms : 0;
241 as_error* err,
as_socket* sock,
struct as_node_s* node, uint8_t *buf,
size_t buf_len,
242 uint32_t socket_timeout, uint64_t deadline
252 as_error* err,
as_socket* sock,
struct as_node_s* node, uint8_t *buf,
size_t buf_len,
253 uint32_t socket_timeout, uint64_t deadline
static bool as_socket_use_tls(as_tls_context *ctx)
as_status as_socket_error(as_socket_fd fd, struct as_node_s *node, as_error *err, as_status status, const char *msg, int code)
void as_socket_init(as_socket *sock)
int as_socket_validate_fd(as_socket_fd fd)
static uint64_t as_socket_deadline(uint32_t timeout_ms)
void as_socket_error_append(as_error *err, struct sockaddr *addr)
static bool as_socket_current_tran(uint64_t last_used, uint64_t max_socket_idle_ns)
int as_socket_create_fd(int family, as_socket_fd *fdp)
void as_socket_close(as_socket *sock)
static bool as_socket_connect_fd(as_socket_fd fd, struct sockaddr *addr, socklen_t size)
int as_socket_create(as_socket *sock, int family, as_tls_context *ctx, const char *tls_name)
bool as_socket_wrap(as_socket *sock, int family, as_socket_fd fd, as_tls_context *ctx, const char *tls_name)
as_status as_socket_read_deadline(as_error *err, as_socket *sock, struct as_node_s *node, uint8_t *buf, size_t buf_len, uint32_t socket_timeout, uint64_t deadline)
as_status as_socket_create_and_connect(as_socket *sock, as_error *err, struct sockaddr *addr, as_tls_context *ctx, const char *tls_name, uint64_t deadline_ms)
bool as_socket_start_connect(as_socket *sock, struct sockaddr *addr, uint64_t deadline_ms)
static as_tls_context * as_socket_get_tls_context(as_tls_context *ctx)
as_status as_socket_write_deadline(as_error *err, as_socket *sock, struct as_node_s *node, uint8_t *buf, size_t buf_len, uint32_t socket_timeout, uint64_t deadline)
static bool as_socket_current_trim(uint64_t last_used, uint64_t max_socket_idle_ns)
struct as_conn_pool_s * pool
struct ssl_ctx_st * ssl_ctx
struct evp_pkey_st * pkey