diff options
author | David Walter Seikel | 2013-01-13 17:29:19 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-13 17:29:19 +1000 |
commit | 07274513e984f0b5544586c74508ccd16e7dcafa (patch) | |
tree | b32ff2a9136fbc1a4a6a0ed1e4d79cde0f5f16d9 /libraries/ecore/src/examples/ecore_con_server_example.c | |
parent | Added Irrlicht 1.8, but without all the Windows binaries. (diff) | |
download | SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.zip SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.gz SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.bz2 SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.xz |
Remove EFL, since it's been released now.
Diffstat (limited to '')
-rw-r--r-- | libraries/ecore/src/examples/ecore_con_server_example.c | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/libraries/ecore/src/examples/ecore_con_server_example.c b/libraries/ecore/src/examples/ecore_con_server_example.c deleted file mode 100644 index 5423eb1..0000000 --- a/libraries/ecore/src/examples/ecore_con_server_example.c +++ /dev/null | |||
@@ -1,81 +0,0 @@ | |||
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 | /* comment if not using gnutls */ | ||
10 | static void | ||
11 | tls_log_func(int level, const char *str) | ||
12 | { | ||
13 | fprintf(stderr, "|<%d>| %s", level, str); | ||
14 | } | ||
15 | |||
16 | Eina_Bool | ||
17 | _add(void *data, int type, Ecore_Con_Event_Client_Add *ev) | ||
18 | { | ||
19 | printf("Client with ip %s connected!\n", ecore_con_client_ip_get(ev->client)); | ||
20 | ecore_con_client_send(ev->client, "hello!", 6); | ||
21 | // ecore_con_client_flush(ev->client); | ||
22 | ecore_con_client_timeout_set(ev->client, 5); | ||
23 | |||
24 | return ECORE_CALLBACK_RENEW; | ||
25 | } | ||
26 | |||
27 | |||
28 | Eina_Bool | ||
29 | _del(void *data, int type, Ecore_Con_Event_Client_Del *ev) | ||
30 | { | ||
31 | printf("Lost client with ip %s!\n", ecore_con_client_ip_get(ev->client)); | ||
32 | ecore_main_loop_quit(); | ||
33 | return ECORE_CALLBACK_RENEW; | ||
34 | } | ||
35 | |||
36 | Eina_Bool | ||
37 | _data(void *data, int type, Ecore_Con_Event_Client_Data *ev) | ||
38 | { | ||
39 | char fmt[128]; | ||
40 | |||
41 | snprintf(fmt, sizeof(fmt), | ||
42 | "Received %i bytes from client:\n" | ||
43 | ">>>>>\n" | ||
44 | "%%.%is\n" | ||
45 | ">>>>>\n", | ||
46 | ev->size, ev->size); | ||
47 | |||
48 | printf(fmt, ev->data); | ||
49 | return ECORE_CALLBACK_RENEW; | ||
50 | } | ||
51 | int main() | ||
52 | { | ||
53 | Ecore_Con_Server *svr; | ||
54 | eina_init(); | ||
55 | ecore_init(); | ||
56 | ecore_con_init(); | ||
57 | |||
58 | /* comment if not using gnutls */ | ||
59 | gnutls_global_set_log_level(9); | ||
60 | gnutls_global_set_log_function(tls_log_func); | ||
61 | |||
62 | |||
63 | /* to use a PEM certificate with TLS and SSL3, uncomment the lines below */ | ||
64 | if (!(svr = 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))) | ||
65 | |||
66 | /* to use simple tcp with ssl/tls, use this line */ | ||
67 | // if (!ecore_con_server_add(ECORE_CON_REMOTE_TCP | ECORE_CON_USE_SSL3, "127.0.0.1", 8080, NULL)) | ||
68 | exit(1); | ||
69 | |||
70 | ecore_con_ssl_server_cert_add(svr, "server.pem"); | ||
71 | ecore_con_ssl_server_privkey_add(svr, "server.pem"); | ||
72 | /* set event handler for client connect */ | ||
73 | ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, (Ecore_Event_Handler_Cb)_add, NULL); | ||
74 | /* set event handler for client disconnect */ | ||
75 | ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, (Ecore_Event_Handler_Cb)_del, NULL); | ||
76 | /* set event handler for receiving client data */ | ||
77 | ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, (Ecore_Event_Handler_Cb)_data, NULL); | ||
78 | |||
79 | /* start server */ | ||
80 | ecore_main_loop_begin(); | ||
81 | } | ||