diff options
author | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
commit | dd7595a3475407a7fa96a97393bae8c5220e8762 (patch) | |
tree | e341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/ecore/src/examples/ecore_server_bench.c | |
parent | Add the skeleton. (diff) | |
download | SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.zip SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.gz SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.bz2 SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.xz |
Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje.
Note that embryo wont be used, but I'm not sure yet if you can build edje without it.
Diffstat (limited to '')
-rw-r--r-- | libraries/ecore/src/examples/ecore_server_bench.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/libraries/ecore/src/examples/ecore_server_bench.c b/libraries/ecore/src/examples/ecore_server_bench.c new file mode 100644 index 0000000..db0020c --- /dev/null +++ b/libraries/ecore/src/examples/ecore_server_bench.c | |||
@@ -0,0 +1,62 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <Ecore.h> | ||
3 | #include <Ecore_Con.h> | ||
4 | |||
5 | /* Ecore_Con server example | ||
6 | * 2010 Mike Blumenkrantz | ||
7 | */ | ||
8 | |||
9 | static Ecore_Con_Server *svr; | ||
10 | static int add; | ||
11 | static int del; | ||
12 | |||
13 | Eina_Bool | ||
14 | _add(void *data, int type, Ecore_Con_Event_Client_Add *ev) | ||
15 | { | ||
16 | ++add; | ||
17 | // printf ("%s ", ecore_con_client_ip_get(ev->client)); | ||
18 | printf("Client #%i!\n", add); | ||
19 | return ECORE_CALLBACK_RENEW; | ||
20 | } | ||
21 | |||
22 | Eina_Bool | ||
23 | _del(void *data, int type, Ecore_Con_Event_Client_Del *ev) | ||
24 | { | ||
25 | ++del; | ||
26 | printf("Disconnected #%i!\n", del); | ||
27 | if (add == del) | ||
28 | ecore_main_loop_quit(); | ||
29 | return ECORE_CALLBACK_RENEW; | ||
30 | } | ||
31 | |||
32 | int main(int argc, const char *argv[]) | ||
33 | { | ||
34 | ecore_init(); | ||
35 | ecore_con_init(); | ||
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); | ||
39 | |||
40 | |||
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))) | ||
43 | |||
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); | ||
46 | if (!svr) | ||
47 | exit(1); | ||
48 | |||
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); | ||
51 | |||
52 | /* start server */ | ||
53 | ecore_main_loop_begin(); | ||
54 | if (add && del) | ||
55 | { | ||
56 | printf("Restarting server after %i connections\n", add); | ||
57 | add = del = 0; | ||
58 | ecore_con_server_del(svr); | ||
59 | ecore_app_restart(); | ||
60 | } | ||
61 | return 0; | ||
62 | } | ||