我有 F#函数'is_up'像下面这样对ip进行ping操作,它在 FSI REPL (交互式)中可以正常工作,即8.8.8.8为true,而false为8.8.8.1
let pingSender = new Ping()
let is_up (t:int) (ip:string) =
let reply = pingSender.Send(IPAddress.Parse(ip),t)
reply.Status = IPStatus.Success
但不是来自main。在这里,我总是很沮丧。
[<EntryPoint>]
let main argv =
let mutable ip = argv.[0];
if is_up 3 ip then
printfn "Host %A is up" ip
else
printfn "Host %A is down" ip
1