5 /* Ecore_Con server example
6 * 2010 Mike Blumenkrantz
9 static Ecore_Con_Server *svr;
14 _add(void *data, int type, Ecore_Con_Event_Client_Add *ev)
17 // printf ("%s ", ecore_con_client_ip_get(ev->client));
18 printf("Client #%i!\n", add);
19 return ECORE_CALLBACK_RENEW;
23 _del(void *data, int type, Ecore_Con_Event_Client_Del *ev)
26 printf("Disconnected #%i!\n", del);
28 ecore_main_loop_quit();
29 return ECORE_CALLBACK_RENEW;
32 int main(int argc, const char *argv[])
36 ecore_app_args_set(argc, argv);
37 eina_log_domain_level_set("ecore_con", EINA_LOG_LEVEL_ERR);
38 eina_log_domain_level_set("eina", EINA_LOG_LEVEL_ERR);
41 /* to use a PEM certificate with TLS and SSL3, uncomment the lines below */
42 // if (!(svr = ecore_con_server_add(ECORE_CON_REMOTE_NODELAY | ECORE_CON_USE_MIXED | ECORE_CON_LOAD_CERT, "127.0.0.1", 8080, NULL)))
44 /* to use simple tcp with ssl/tls, use this line */
45 svr = ecore_con_server_add(ECORE_CON_REMOTE_NODELAY , "127.0.0.1", 8080, NULL);
49 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, (Ecore_Event_Handler_Cb)_add, NULL);
50 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, (Ecore_Event_Handler_Cb)_del, NULL);
53 ecore_main_loop_begin();
56 printf("Restarting server after %i connections\n", add);
58 ecore_con_server_del(svr);