Commit 483e5211 authored by Josh Kunz's avatar Josh Kunz

Now accepting clients.

parent 6bb5503e
......@@ -2,7 +2,7 @@
OCAMLLEX_FLAGS =
OCAMLYACC_FLAGS =
OCAMLFLAGS = -thread -I ../include/
OCAMLFLAGS = -thread -I ../include/
bin = nagad
......@@ -10,17 +10,17 @@ sources = KG.ml Query.ml Nagad.ml
interfaces = $(patsubst %.mli,%.cmi,$(filter %.mli,$(sources)))
interfaces += $(patsubst %.ml,%.cmi,$(filter %.ml,$(sources)))
objects = $(patsubst %.ml,%.cmo,$(filter %.ml,$(sources)))
libs = json http
system_libs = unix threads
local_libs = json http
depfile = Makefile.d
abs_libs = $(addprefix ../lib/,$(addsuffix .cma,$(libs)))
default: $(bin)
$(depfile): $(sources)
abs_libs = $(addprefix ../lib/,$(addsuffix .cma,$(local_libs)))
$(bin): $(abs_libs) $(objects)
ocamlc $(OCAMLFLAGS) -o $@ $^
ocamlc $(OCAMLFLAGS) -o $@ $(addsuffix .cma,$(system_libs)) $^
clean:
-rm -f $(bin) $(objects) $(interfaces) $(depfile)
......
open Sys
open Printf
open Unix
open List
open KG
open Query
open HTTP
open Thread
open Mutex;;
open Mutex
let g = KG.empty () in
KG.madd_fact g {head="a"; rel="b"; tail="c"};
KG.madd_fact g {head="c"; rel="b"; tail="a"};
KG.madd_fact g {head="c"; rel="b"; tail="c"};
KG.madd_fact g {head="c"; rel="b"; tail="a"};
let query = [{head=Variable "A"; rel=Variable "B"; tail=Variable "C"};
{head=Variable "C"; rel=Variable "B"; tail=Value "a"}] in
let result = Query.query_graph g query in
printf "Result count: %d\n" (List.length result);
let handle_client (ic, oc, addr) =
print_endline "Got new client!";;
(*
let main () =
let eval_prog = eval_program handle_query handle_statement in
match Sys.argv with
| [| _ |] -> repl () |> ignore
| [| _; "-f"; n |] -> eval_prog (open_in n |> parse_source) [] |> ignore
| _ -> print_endline "Unrecognized flags.";;
let main port =
let tcp = (getprotobyname "tcp").p_proto in
let sock = socket PF_INET SOCK_STREAM tcp in
ADDR_INET (inet_addr_any, port) |> bind sock;
listen sock 10;
main ();;
*)
let rec accept_loop () =
let (csock, addr) = accept sock in
let (ic, oc) = (in_channel_of_descr csock, out_channel_of_descr csock) in
Thread.create handle_client (ic, oc, addr) |> ignore;
accept_loop () in
accept_loop ();;
main 80;;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment