update examples to new api
authordiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 28 Sep 2010 09:41:20 +0000 (09:41 +0000)
committerdiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 28 Sep 2010 09:41:20 +0000 (09:41 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@52847 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

examples/ecore_con_client_example.c
examples/ecore_con_server_example.c

index 00ef6b4..d5af111 100644 (file)
@@ -49,6 +49,7 @@ _data(void *data, int type, Ecore_Con_Event_Server_Data *ev)
 }
 int main()
 {
+   Ecore_Con_Server *svr;
    eina_init();
    ecore_init();
    ecore_con_init();
@@ -58,17 +59,11 @@ int main()
    gnutls_global_set_log_function(tls_log_func);
 
 
-/* to use a PEM certificate with TLS and SSL3, uncomment the lines below */
-/*
-   if ((!ecore_con_server_ssl_cert_add("server.pem")))
-     printf("Error loading certificate!\n");
 
-   ecore_con_server_connect(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 with ssl/tls, use this line */
-   if (!ecore_con_server_connect(ECORE_CON_REMOTE_TCP | ECORE_CON_USE_MIXED, "127.0.0.1", 8080, NULL))
+   if (!(svr = ecore_con_server_connect(ECORE_CON_REMOTE_TCP | ECORE_CON_USE_MIXED, "localhost", 8080, NULL)))
      exit(1);
+   ecore_con_ssl_server_cafile_add(svr, "/etc/ssl/certs/vsign2.pem");
+   ecore_con_ssl_server_verify(svr);
 
 /* set event handler for server connect */
    ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, (Ecore_Event_Handler_Cb)_add, NULL);
index 22010db..5423eb1 100644 (file)
@@ -18,7 +18,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_flush(ev->client);
    ecore_con_client_timeout_set(ev->client, 5);
 
    return ECORE_CALLBACK_RENEW;
@@ -50,6 +50,7 @@ _data(void *data, int type, Ecore_Con_Event_Client_Data *ev)
 }
 int main()
 {
+   Ecore_Con_Server *svr;
    eina_init();
    ecore_init();
    ecore_con_init();
@@ -60,16 +61,14 @@ int main()
 
 
 /* to use a PEM certificate with TLS and SSL3, uncomment the lines below */
-/*
-   if ((!ecore_con_client_ssl_cert_add("server.pem", NULL, "server.pem")))
-     printf("Error loading certificate!\n");
-
-   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);
-*/
+   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)))
 
 /* to use simple tcp with ssl/tls, use this line */
-   if (!ecore_con_server_add(ECORE_CON_REMOTE_TCP | ECORE_CON_USE_SSL3, "127.0.0.1", 8080, NULL))
+//   if (!ecore_con_server_add(ECORE_CON_REMOTE_TCP | ECORE_CON_USE_SSL3, "127.0.0.1", 8080, NULL))
      exit(1);
+
+   ecore_con_ssl_server_cert_add(svr, "server.pem");
+   ecore_con_ssl_server_privkey_add(svr, "server.pem");
 /* set event handler for client connect */
    ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, (Ecore_Event_Handler_Cb)_add, NULL);
 /* set event handler for client disconnect */