How to get the actual sockaddr bound by Unix.(bind (INET_ADDR (inet_addr_any, 0))) ?
Unix.(bind (INET_ADDR (inet_addr_any, 0)))
I want to let system to choose a unused port, and get the port number to tell the client to connect.
Do you mean you want to use Unix.listen?
If you bind, you have to specify the port as far as I know.
Take a look at http://www.masterraghu.com/subjects/np/introduction/unix_network_programming_v1.3/ch04lev1sec4.html
I found it: Unix.getsockname
With Lwt_io.establish_server, I believe you currently have to create your own socket, and pass it in with Lwt_io.establish_server ~fd:my_fd .... You can then call Unix.getsockname my_fd.
Lwt_io.establish_server ~fd:my_fd ...