Add command arguments
This commit is contained in:
parent
3d41a5ff55
commit
e4bdf9a97c
12
udpdup.ml
12
udpdup.ml
|
@ -14,7 +14,17 @@ let rec loop fd dests =
|
|||
|
||||
let main () =
|
||||
let addr = "0.0.0.0" in
|
||||
let dests = ["127.0.0.1", 2234; "127.0.0.1", 2235] in
|
||||
let dests =
|
||||
Array.to_list Sys.argv
|
||||
|> List.tl
|
||||
|> List.map (fun dest ->
|
||||
match String.split_on_char ':' dest with
|
||||
| [host; port] ->
|
||||
host, int_of_string port
|
||||
| _ ->
|
||||
Printf.eprintf "bad argument: %s" dest;
|
||||
exit 1)
|
||||
in
|
||||
let fd = Lwt_unix.socket Lwt_unix.PF_INET Lwt_unix.SOCK_DGRAM 0 in
|
||||
Lwt_unix.bind fd Unix.(ADDR_INET (inet_addr_of_string addr, port)) >>= fun () ->
|
||||
Lwt_list.map_p (fun (addr, port) ->
|
||||
|
|
Loading…
Reference in a new issue