Home > other >  Libevent2 enable iocp
Libevent2 enable iocp

Time:10-28

 
# include & lt; Iostream>
# include & lt; Event2/event. H>
# include & lt; Event2/thread. H>
# include & lt; Csignal>


Void log_callback (int security, const char * MSG)
{
STD: : cout & lt; <"The log: security=" & lt; Abort ();
}


Void event_callback (evutil_socket_t s, short event, void * arg)
{
STD: : cout & lt; <"SIGINT triggered, exit loop" & lt; Struct event_base * eb=(struct event_base *) (arg);
If (eb!=NULL)
{
Event_base_loopexit (eb, NULL);
}
}

Int _tmain (int arg c, _TCHAR * argv [])
{
Event_set_log_callback (log_callback);
Event_set_fatal_callback (fatal_callback);
//event_enable_debug_logging (EVENT_DBG_ALL);
Event_enable_debug_mode ();
Evthread_use_windows_threads ();

Struct event_config * ec=event_config_new ();
Event_config_set_flag (ec, EVENT_BASE_FLAG_STARTUP_IOCP);
Event_config_require_features (ec, EV_FEATURE_ET);

Struct event_base * eb=event_base_new_with_config (ec);
If (eb!=NULL)
{
Struct event * sigint=evsignal_new (eb, sigint, event_callback, eb);

Event_base_dispatch (eb);

Event_base_free (eb);
}
Event_config_free (ec);

return 0;


After this code in the link above libevent2 version, execute event_base_new_with_config (ec) always returns NULL, log_callback print out no event mechanism available, libevent enable iocp do ah, excuse me expert what went wrong this code, thanks a lot
  • Related