|
vttp
An HTTP backed Virtual Table extension for SQLite
|
socket API More...
#include <netdb.h>#include <openssl/ssl.h>#include <openssl/types.h>#include <stdbool.h>
Go to the source code of this file.
Macros | |
| #define | MAX_HOSTNAME_LENGTH 255 |
Functions | |
| int | tcp_getaddrinfo (const char *hostname, const char *port, struct addrinfo **addr) |
| Write address info from HOSTNAME and PORT into ADDR. | |
| int | tcp_socket (struct addrinfo *addrinfo) |
| Open socket fd from ADDRINFO and return it. | |
| int | tcp_connect (int fd, struct sockaddr *addr, socklen_t len, SSL **ssl, SSL_CTX **ctx, const char *hostname) |
connect() to socket FD using ADDR, optionally using TLS if TLS is not NULL. | |
| ssize_t | tcp_send (int fd, const char *bytes, size_t len, SSL *ssl) |
| Send LEN BYTES over tcp connection at FD, potentially writing over the TLS connection at SSL, if it exists. | |
| ssize_t | tcp_recv (int fd, char *bytes, size_t len, SSL *ssl) |
| Maybe recv LEN BYTES over the TCP connection at SSL, if it exists. | |
| void | tcp_tls_free (SSL *ssl, SSL_CTX *ctx) |
| Shutdown and free SSL and CTX. | |
socket API
| int tcp_connect | ( | int | fd, |
| struct sockaddr * | addr, | ||
| socklen_t | len, | ||
| SSL ** | ssl, | ||
| SSL_CTX ** | ctx, | ||
| const char * | hostname | ||
| ) |
connect() to socket FD using ADDR, optionally using TLS if TLS is not NULL.
| 0 | OK |
| -1 | Error connecting to socket |
| -2 | Error with TLS connection |
| int tcp_getaddrinfo | ( | const char * | hostname, |
| const char * | port, | ||
| struct addrinfo ** | addr | ||
| ) |
Write address info from HOSTNAME and PORT into ADDR.
| 0 | OK. Address Info written to ADDR. |
| 22 | EINVAL. At least one of HOSTNAME or PORT or ADDR is NULL. |
| ANYTHING_ELSE | Error. The return value of getaddrinfo() when non-zero. |
| ssize_t tcp_recv | ( | int | fd, |
| char * | bytes, | ||
| size_t | len, | ||
| SSL * | ssl | ||
| ) |
Maybe recv LEN BYTES over the TCP connection at SSL, if it exists.
If SSL is NULL then tcp_recv() fallsback to plain recv() call to SOCKFD.
| -1 | ERROR - Neither the SOCKFD or SSL sockets can be written to. |
| (x | >= 0) OK - X bytes written out. |
| ssize_t tcp_send | ( | int | fd, |
| const char * | bytes, | ||
| size_t | len, | ||
| SSL * | ssl | ||
| ) |
Send LEN BYTES over tcp connection at FD, potentially writing over the TLS connection at SSL, if it exists.
If SSL is NULL, then tcp_send() fallsback to plain send() call to SOCKFD.
| -1 | ERROR - Neither the SOCKFD or SSL sockets can be written to. |
| x>=0 | OK - x bytes written out. |
| int tcp_socket | ( | struct addrinfo * | addrinfo | ) |
Open socket fd from ADDRINFO and return it.
| -1 | Error opening socket. |
| NONNEGATIVE | OK, a socket file descriptor. |
| void tcp_tls_free | ( | SSL * | ssl, |
| SSL_CTX * | ctx | ||
| ) |
Shutdown and free SSL and CTX.
If both SSL and CTX are NULL, then this is a no-op.