AISL Instance Type and Functions
/* @file aisl/types.h */
typedef struct aisl_instance * AislInstance;
Pointer of this type represents library engine instance. One instance can run several independent HTTP servers on different network sockets.
Functions
Function aisl_new
A constructor of AislInstance type.
AislInstance
aisl_new(const struct aisl_cfg *cfg);
Arguments
cfg
— a pointer to aisl_cfg configuration structure
Return value
Pointer to an AislInstance
or NULL
if out of memory.
Function aisl_free
A destructor of AislInstance
object.
void
aisl_free(AislInstance instance);
Arguments
instance
— a pointer to anAislInstance
.
Return value
Returns no value.
Function aisl_run_cycle
Performs an engine work cycle including all queued read and write sockets operations, accepts new clients and triggers engine events. Should be called periodically in a main loop of the application.
AislStatus
aisl_run_cycle(AislInstance instance);
Arguments
instance
— a pointer to anAislInstance
.
Return value
AISL_SUCCESS
— if some event was triggeredAISL_IDLE
— if no event was triggeredAISL_MALLOC_ERROR
— if system run out of memoryAISL_SYSCALL_ERROR
— if some system call failed
Return value handling should be soft. It is completely safe to continue program execution even if error value was returned.
To preserve CPU time it is recommended to add a delay between
aisl_run_cycle calls, at least if anything but
AISL_SUCCESS
has been returned. You may want to use
aisl_sleep for this.
Function aisl_sleep
This function runs select system call inside on all opened sockets for read or write depending on a stream state for user defined timeout.
AislStatus
aisl_sleep(AislInstance instance, uint32_t usec);
Arguments
instance
— a pointer to anAislInstance
.usec
— a maximum possible timeout in microseconds for execution blocking
Return value
AISL_SUCCESS
— if some socket is ready for an operationAISL_IDLE
— if timed out without any activity on socketsAISL_SYSCALL_ERROR
— if select() system call failed