From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p1OJBlcl016462 for ; Thu, 24 Feb 2011 20:11:47 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnADAE48Zk1HSjh9kWdsb2JhbACYHY4VFQEBAgkLEREDIb4ohWAEhRCHDIM9 X-IronPort-AV: E=Sophos;i="4.62,219,1297033200"; d="scan'208";a="88648331" Received: from hrndva-omtalb.mail.rr.com ([71.74.56.125]) by mail4-smtp-sop.national.inria.fr with ESMTP; 24 Feb 2011 20:11:41 +0100 X-Authority-Analysis: v=1.1 cv=UQuFHoD2CPQ248x8AXEbKhr4z9AaDqApxmEl3BhfZ64= c=1 sm=0 a=kj9zAlcOel0A:10 a=JniiaRPG9VhsXGqxK7cJ8g==:17 a=lfPjWLu3sgHpDy_Yy8QA:9 a=1OVMbNCnLa5RfVxpNigA:7 a=d-xfNiWCCnFG8YdtKdrvkNVBPCwA:4 a=CjuIK1q_8ugA:10 a=JniiaRPG9VhsXGqxK7cJ8g==:117 X-Cloudmark-Score: 0 X-Originating-IP: 74.66.5.119 Received: from [74.66.5.119] ([74.66.5.119:49759] helo=[192.168.1.3]) by hrndva-oedge02.mail.rr.com (envelope-from ) (ecelerity 2.2.3.46 r()) with ESMTP id BE/E5-00963-C6DA66D4; Thu, 24 Feb 2011 19:11:41 +0000 From: Pierre Chopin Content-Type: text/plain; charset=us-ascii Date: Thu, 24 Feb 2011 14:11:40 -0500 Message-Id: <72F1256E-1783-45EC-8A18-EA286B290E51@free.fr> To: caml-list@inria.fr Mime-Version: 1.0 (Apple Message framework v1082) X-Mailer: Apple Mail (2.1082) Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p1OJBlcl016462 Subject: [Caml-list] ocaml-ssl Hi, I am trying to get familiar with the ocaml-ssl bindings for Opensll. Thus, I am trying to establish an SSL connection between a server and a client which are on my computer. I therefore create two sockets, establish a tcp connection between then, and then fail to establish SSL communication. The function Ssl.accept on the server will return Accept_error Error_want_read, which I believe is due to the fact that somehow the socket is used in non-blocking mode. I therefore made a loop to constantly check for accepting connection. I am not familiar with non blocking mode so I don't know if it is right. Here is the code for the server. (* #directory "/opt/local/lib/ocaml/site-lib/ssl/";; #load "ssl.cma" ;; #load "unix.cma" *) open Ssl ;; open Unix;; init () ;; let domain = PF_INET ;; let ty = SOCK_STREAM ;; let usock = socket domain ty 0;; let name =Unix.gethostname () ;; let h = Unix.gethostbyname name ;; let inet = h.h_addr_list.(0) ;; let cont = create_context SSLv3 Server_context ;; let sock_addr = Unix.ADDR_INET (inet,22211) ;; bind usock sock_addr ;; listen usock 3 ;; accept usock ;; print_string "TCP connection established\n" ;; Pervasives.flush Pervasives.stdout ;; let sock = embed_socket usock cont ;; while true do try Ssl.accept sock ;; print_endline "bing" ; Pervasives.flush Pervasives.stdout with Ssl.Accept_error Error_want_read -> sleep 1; print_endline "looping" ;Pervasives.flush Pervasives.stdout done; Concerning the client, it's pretty much a mirror of the server, except for the loop: #directory "/opt/local/lib/ocaml/site-lib/ssl/";; #load "/opt/local/lib/ocaml/site-lib/ssl/ssl.cma" ;; #load "unix.cma" open Ssl ;; open Unix;; init () ;; let domain = PF_INET ;; let ty = SOCK_STREAM ;; let usock = socket domain ty 0;; let name =Unix.gethostname () ;; let h = Unix.gethostbyname name ;; let inet = h.h_addr_list.(0) ;; let cont = create_context SSLv3 Client_context ;; let sock_addr = Unix.ADDR_INET (inet,22211) ;; connect usock sock_addr;; let sock =embed_socket usock cont ;; let usock2 = file_descr_of_socket sock ;; Ssl.connect sock ;; That last function never returns, and the server keeps "looping", until i kill the process. Any idea why? Sincerly, Pierre