asynchronous - Simple UDP server OCaml/Async -


i'm trying simple udp server using ocaml , async api i'm stuck. can't make simple example work.

let wait_for_datagram () : unit deferred.t =    let port = 9999 in   let addr = socket.address.inet.create unix.inet_addr.localhost ~port in   let%bind socket = udp.bind addr in    let socket = socket.fd socket in   let stop = never () in   let config = udp.config.create ~stop () in   let callback buf _ : unit = failwith "got datagram" in   udp.recvfrom_loop ~config socket callback  

i test with:

echo -n "hello goodbye" > /dev/udp/localhost/9999 

nothing happens in program. tried investigate other tools.

i see destination unreachable packet wireshark , lsof shows me this:

> lsof -i :9999  command    pid     user   fd   type             device size/off node name main.exe 77564     nemo   5u   ipv4 0x25251bcc3485235f      0t0  udp localhost:distinct 

what doing wrong here?

the code looks ok me. think localhost resolved ipv6 address default, , send there.

try force using ipv4 protocol

echo -n "hello goodbye" | nc -4 -u -w0 localhost 9999 

or specify explicit ipv4 address

echo -n "hello goodbye" > /dev/udp/127.0.0.1/9999 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -