Example #1
0
/** 
 * @internal nopoll implementation to create a compatible "select" IO
 * call fd set reference.
 *
 * @return A newly allocated fd_set reference.
 */
noPollPtr nopoll_io_wait_select_create (noPollCtx * ctx) 
{
	noPollSelect * select = nopoll_new (noPollSelect, 1);

	/* set default behaviour expected for the set */
	select->ctx           = ctx;
	
	/* clear the set */
	FD_ZERO (&(select->set));

	return select;
}
/** 
 * @brief Create a new connection options object.
 *
 * @return A newly created connection options object. In general you don't have to worry about releasing this object because this is automatically done by functions using this object. However, if you call to \ref nopoll_conn_opts_set_reuse (opts, nopoll_true), then you'll have to use \ref nopoll_conn_opts_free to release the object after it is no longer used. The function may return NULL in case of memory allocation problems. Creating an object without setting anything will cause the library to provide same default behaviour as not providing it.
 */
noPollConnOpts * nopoll_conn_opts_new (void)
{
	noPollConnOpts * result;

	/* create configuration object */
	result = nopoll_new (noPollConnOpts, 1);
	if (! result)
		return NULL;

	result->reuse        = nopoll_false; /* this is not needed, just to clearly state defaults */
	result->ssl_protocol = NOPOLL_METHOD_TLSV1;

	result->mutex        = nopoll_mutex_create ();
	result->refs         = 1;

	/* by default, disable ssl peer verification */
	result->disable_ssl_verify = nopoll_true;

	return result;
}
Example #3
0
/** 
 * @brief Creates an object that represents the best IO wait mechanism
 * found on the current system.
 *
 * @param ctx The context where the engine will be created/associated.
 *
 * @param engine Use \ref NOPOLL_IO_ENGINE_DEFAULT or the engine you
 * want to use.
 *
 * @return The selected IO wait mechanism or NULL if it fails.
 */ 
noPollIoEngine * nopoll_io_get_engine (noPollCtx * ctx, noPollIoEngineType engine_type)
{
	noPollIoEngine * engine = nopoll_new (noPollIoEngine, 1);
	if (engine == NULL)
		return NULL;

	/* configure default implementation */
	engine->create  = nopoll_io_wait_select_create;
	engine->destroy = nopoll_io_wait_select_destroy;
	engine->clear   = nopoll_io_wait_select_clear;
	engine->wait    = nopoll_io_wait_select_wait;
	engine->addto   = nopoll_io_wait_select_add_to;
	engine->isset   = nopoll_io_wait_select_is_set;

	/* call to create the object */
	engine->ctx       = ctx;
	engine->io_object = engine->create (ctx);
	
	/* return the engine that was created */
	return engine;
}