Browse Source

Add unix socket experiments

rexim 6 years ago
parent
commit
06df77ee0a
5 changed files with 32 additions and 3 deletions
  1. 6 3
      TODO.org
  2. 7 0
      unix-socket/.gitignore
  3. 7 0
      unix-socket/Makefile
  4. 6 0
      unix-socket/client.ml
  5. 6 0
      unix-socket/server.ml

+ 6 - 3
TODO.org

@@ -13,9 +13,12 @@
     - [-] [[file:ocaml-hotreload/][file:./ocaml-hotreload/]]
     - [-] [[file:ocaml-hotreload/][file:./ocaml-hotreload/]]
       - [X] [[https://jaredforsyth.com/posts/hot-reloading-ocaml-on-web-desktop-and-android/][Hot-reloading OCaml on Web, Desktop, and Android | Jared Forsyth.com]]
       - [X] [[https://jaredforsyth.com/posts/hot-reloading-ocaml-on-web-desktop-and-android/][Hot-reloading OCaml on Web, Desktop, and Android | Jared Forsyth.com]]
         - [X] Dynlink.load does not exist
         - [X] Dynlink.load does not exist
-      - [ ] [[http://zderadicka.eu/plugins-in-ocaml-with-dynlink-library/][Plugins in OCAML with Dynlink library | Ivanovo]]
-        - [ ] Works perfectly!
-          - [ ] Except native plugins
+      - [X] [[http://zderadicka.eu/plugins-in-ocaml-with-dynlink-library/][Plugins in OCAML with Dynlink library | Ivanovo]]
+        - [X] Works perfectly!
+          - [X] Except native plugins
+	    - [X] And I need native to interact with C code
+      - [ ] Client Server architecture
+	- [ ] [[file:unix-socket/][file:./unix-socket/]]
 - [X] Functional Programming with Static typing
 - [X] Functional Programming with Static typing
   - [X] OCaml
   - [X] OCaml
     - [X] [[https://www.linux-nantes.org/~fmonnier/OCaml/ocaml-wrapping-c.html][How to wrap C functions to OCaml]]
     - [X] [[https://www.linux-nantes.org/~fmonnier/OCaml/ocaml-wrapping-c.html][How to wrap C functions to OCaml]]

+ 7 - 0
unix-socket/.gitignore

@@ -0,0 +1,7 @@
+*.cma
+*.cmi
+*.cmo
+*.cmx
+*.cmxs
+*.o
+*.opt

+ 7 - 0
unix-socket/Makefile

@@ -0,0 +1,7 @@
+all: client.opt server.opt
+
+client.opt: client.ml
+	ocamlfind ocamlopt -linkpkg -package unix -o client.opt client.ml
+
+server.opt: server.ml
+	ocamlfind ocamlopt -linkpkg -package unix -o server.opt server.ml

+ 6 - 0
unix-socket/client.ml

@@ -0,0 +1,6 @@
+let _ =
+  let (inc, outc) =
+    Unix.open_connection (Unix.ADDR_UNIX "khooy")
+  in output_value outc "VI VON ZULUL";
+     flush outc;
+     inc |> input_value |> print_endline

+ 6 - 0
unix-socket/server.ml

@@ -0,0 +1,6 @@
+let _ =
+  Unix.establish_server
+    (fun inc outc ->
+      let x : string = input_value inc in
+      output_value outc ("Server Response: " ^ x))
+    (Unix.ADDR_UNIX "khooy")