open Unix;; type event = {start : int; finish : int; info : string } type day = (string*event) list;; type agenda = day array;; type operation = | Get_agenda (** demander les informations de tout l'agenda *) | Get_day of int (** demander les informations sur une journée *) | Add_event of string * int * int * int * string (** (nom, jour, heure début, heure fin, info) ajouter une entrée, le nom droit être unique le jour donné *) | Delete_event of string * int (** (jour, nom) supprimer les informations de la journée donnée avec le nom donné *) ;; type result = | Unit | Agenda of agenda | Day of day | Exception of exn ;; let open_connection address port = let socket = socket PF_INET SOCK_STREAM 0 in (* bind socket (ADDR_INET (inet_addr_any, 0));*) connect socket (ADDR_INET (address,port)); socket;; let remote_query address port (o : operation) = let sock = open_connection address port in let out_channel = out_channel_of_descr sock in output_value out_channel o; Pervasives.flush out_channel; let v = input_value (in_channel_of_descr sock) in close sock; (v : result) |