Usage
anntp is a single-header library. This means you can just vendor it, add a -I C preprocessor flag and use it.
Including the implementation
You’ll be familiar with this if you’ve ever used an stb library.
Define the ANNTP_IMPLEMENTATION macro in exactly one file,* else you will get many linker errors:
You can also define a couple more macros to configure the library in a similar fashion, those will be covered later:
/* file1.h */
#define ANNTP_IMPLEMENTATION
#include <anntp.h>
/* file2.h */
#include <anntp.h>
Some folks also like to make a separate C file with the implementations; it’s worth it if you also use other single-header libraries.
IMPORTANT: You must define
_POSIX_C_SOURCEto200112Lbefore including this library
Configuring anntp
You should be familiar with these macros:
ANNTP_TLS: If defined, enable TLSANNTP_BUFSIZE: Set buffer sizes, for all functions not in thecbfamily.ANNTP_MALLOCandANNTP_FREE: Memory allocatorsANNTP_STRDUP: string duplication function, by default a portable-ish thingANNTP_API: stuff to put before all function declarations and function definitions
API
The API is based on connections. Connections abstract the TCP channel between a server and client.
They contain lots of data and things for the library of course, but most importantly, they contain the read and write buffers. All I/O functions operate on these.
To post a comment you need to login first.