caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Async Server not executing
@ 2015-06-16 15:03 Kenneth Adam Miller
  2015-06-16 15:09 ` David House
  0 siblings, 1 reply; 8+ messages in thread
From: Kenneth Adam Miller @ 2015-06-16 15:03 UTC (permalink / raw)
  To: caml users

[-- Attachment #1: Type: text/plain, Size: 1158 bytes --]

I'm having trouble with OCaml Async. I wrote a small server with it, and
right now I'm trying to unit test that server. Here's my code for the
server:


let _main ()=
  print_endline "Server running";
  let handler = print_endline in
  let socket = Tcp.on_port 5554 in
  let server = Tcp.Server.create socket (fun addr r w ->
      (Reader.contents r) >>| handler; (Writer.write w "got it")) in
  server



In my unit test code I have:

let test_shutdown test_ctxt = Thread_safe.block_on_async_exn (fun () -> (
      print_endline "test_shutdown";
      let server = Server._main () in
      server >>= fun server ->
      let where = Tcp.to_host_and_port "127.0.0.1" 5554 in
      Tcp.connect where >>= fun s ->
        let socket, r, w = s in
        ignore (Writer.write w "kill");
        ignore (Writer.flushed w);
        (Reader.recv r >>> function
          | `Ok result ->  print_endline ("writing shutdown to server" ^
result)
          | `Eof -> ());
        return ()
    )); ()



I see test_shutdown and Server running, but not sign of "writing shutdown
to server" or even "got it"; why isn't my server or even any of the
connection executing?

[-- Attachment #2: Type: text/html, Size: 19448 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-06-17 14:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-16 15:03 [Caml-list] Async Server not executing Kenneth Adam Miller
2015-06-16 15:09 ` David House
2015-06-16 15:36   ` Kenneth Adam Miller
2015-06-16 15:41     ` David House
2015-06-16 15:48       ` Kenneth Adam Miller
2015-06-16 17:50         ` Kenneth Adam Miller
2015-06-17  8:09           ` David House
2015-06-17 14:57             ` Kenneth Adam Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).