From af23a6685717cf2b784993202fba99afe11ddcf4 Mon Sep 17 00:00:00 2001 From: discomfitor Date: Wed, 22 Sep 2010 17:22:11 +0000 Subject: [PATCH] update to use automatic disconnect and quit after a connection git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@52596 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- examples/ecore_con_server_example.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/examples/ecore_con_server_example.c b/examples/ecore_con_server_example.c index d87d25d..ba9e55d 100644 --- a/examples/ecore_con_server_example.c +++ b/examples/ecore_con_server_example.c @@ -6,13 +6,12 @@ * 2010 Mike Blumenkrantz */ -/* uncomment if using gnutls +/* comment if not using gnutls */ static void tls_log_func(int level, const char *str) { fprintf(stderr, "|<%d>| %s", level, str); } -*/ Eina_Bool _add(void *data, int type, Ecore_Con_Event_Client_Add *ev) @@ -20,7 +19,7 @@ _add(void *data, int type, Ecore_Con_Event_Client_Add *ev) printf("Client with ip %s connected!\n", ecore_con_client_ip_get(ev->client)); ecore_con_client_send(ev->client, "hello!", 6); ecore_con_client_flush(ev->client); - ecore_con_client_del(ev->client); + ecore_con_client_timeout_set(ev->client, 5); return ECORE_CALLBACK_RENEW; } @@ -30,6 +29,7 @@ Eina_Bool _del(void *data, int type, Ecore_Con_Event_Client_Del *ev) { printf("Lost client with ip %s!\n", ecore_con_client_ip_get(ev->client)); + ecore_main_loop_quit(); return ECORE_CALLBACK_RENEW; } @@ -54,10 +54,9 @@ int main() ecore_init(); ecore_con_init(); -/* uncomment if using gnutls +/* comment if not using gnutls */ gnutls_global_set_log_level(9); gnutls_global_set_log_function(tls_log_func); -*/ /* to use a PEM certificate with TLS and SSL3, uncomment the lines below */ @@ -68,8 +67,8 @@ int main() ecore_con_server_add(ECORE_CON_REMOTE_TCP | ECORE_CON_USE_TLS | ECORE_CON_USE_SSL3 | ECORE_CON_LOAD_CERT, "127.0.0.1", 8080, NULL); */ -/* to use simple tcp without ssl/tls, use this line */ - ecore_con_server_add(ECORE_CON_REMOTE_TCP, "127.0.0.1", 8080, NULL); +/* to use simple tcp with ssl/tls, use this line */ + ecore_con_server_add(ECORE_CON_REMOTE_TCP | ECORE_CON_USE_MIXED, "127.0.0.1", 8080, NULL); /* set event handler for client connect */ ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, (Ecore_Event_Handler_Cb)_add, NULL); -- 2.7.4