anchor.diff:      assert (s >= 0)
       let eid = NN.Connect(s, ca)
       assert (eid >= 0)
  -    let rec recvloop () =
  +    let rec recvloop() = 
           //let mutable buff : byte[] = null '\000'
           //log.Info("[{0}] Ormonit test receive (blocking).", lid)
           match recv s with
  -        | Error (errn, errm) ->
  +        | Error(errn, errm) -> 
               sprintf """[%i] Error %i (recv). %s.""" lid errn errm |> log.Error
  -            recvloop ()
  -        | Msg (_, note) ->
  -        let nparts = note.Split([|' '|], StringSplitOptions.RemoveEmptyEntries)
  -        let cmd = if nparts.Length > 0 then nparts.[0] else String.Empty
  -        let args = List.ofArray (if nparts.Length > 1 then nparts.[1..] else [||])
  -        //let parsed = Cli.parseArgs args
  -        sprintf "[%i] Ormonit test \"%s\" note received. (%s)" lid note cmd |> log.Info
  -        match cmd with
  -        | "close" ->
  -            let flag = lock mlock (fun () -> continu <- false; continu)
  -            //log.Trace("""[{0}] Processing "close" notification. continue value {1}""", lid, flag)
  -            log.Trace("""[{0}] Sending "close" aknowledgement.""", lid)
  -            match Msg(config.["ckey"], "closing") |> send s with
  -            | Error (errn, errm) ->
  -                sprintf """Error %i (send). %s.""" errn errm |> log.Error
  -                recvloop ()
  -            | Msg _ ->
  -                //log.Trace("""[{0}] Sent "close" aknowledgement.""", lid)
  -                ()
  -        | "report-status" ->
  -            let rand = Random().NextDouble()
  -            if rand > 0.8 then
  -                //log.Trace("""[{0}] Processing "report-status" command.""", lid)
  -                log.Trace("""[{0}] Sending "report-status" aknowledgement.""", lid)
  -                match Msg(config.["ckey"], "ok") |> send s with
  -                | Error (errn, errm) ->
  +            recvloop()
  +        | Msg(_, note) -> 
  +            let nparts = note.Split([| ' ' |], StringSplitOptions.RemoveEmptyEntries)
  +            
  +            let cmd = 
  +                if nparts.Length > 0 then nparts.[0]
  +                else String.Empty
  +            
  +            let args = 
  +                List.ofArray (if nparts.Length > 1 then nparts.[1..]
  +                              else [||])
  +            
  +            //let parsed = Cli.parseArgs args
  +            sprintf "[%i] Ormonit test \"%s\" note received. (%s)" lid note cmd |> log.Info
  +            match cmd with
  +            | "close" -> 
  +                let flag = 
  +                    lock mlock (fun () -> 
  +                        continu <- false
  +                        continu)
  +                //log.Trace("""[{0}] Processing "close" notification. continue value {1}""", lid, flag)
  +                log.Trace("""[{0}] Sending "close" aknowledgement.""", lid)
  +                match Msg(config.["ckey"], "closing") |> send s with
  +                | Error(errn, errm) -> 
                       sprintf """Error %i (send). %s.""" errn errm |> log.Error
  -                | Msg _ ->
  -                    //log.Trace("""[{0}] Sent "report-status" aknowledgement.""", lid)
  -                    ()
  -            else
  -                log.Warn("""[{0}] Processing "report-status" failed (simulated).""", lid)
  -            recvloop ()
  -        | "sys:client-key" ->
  -            log.Trace("[{0}] Sending client-key: '{1}'.", lid, config.["ckey"])
  -            let encrypted = encrypt config.["publicKey"] config.["ckey"]
  -            let note = Convert.ToBase64String(encrypted)
  -            match Msg(lid.ToString(), note) |> send s with
  -            | Error (errn, errm) ->
  -                sprintf """Error %i (send). %s.""" errn errm |> log.Error
  -            | Msg _ ->
  -                log.Trace("[{0}] Sent client-key: '{1}'.", lid, config.["ckey"])
  -            recvloop ()
  -        | _ -> recvloop ()
  -    recvloop ()
  -    assert(NN.Shutdown(s, eid) = 0)
  -    assert(NN.Close(s) = 0)
  +                    recvloop()
  +                | Msg _ -> ()
  +            //log.Trace("""[{0}] Sent "close" aknowledgement.""", lid)
  +            | "report-status" -> 
  +                let rand = Random().NextDouble()
  +                if rand > 0.8 then 
  +                    //log.Trace("""[{0}] Processing "report-status" command.""", lid)
  +                    log.Trace("""[{0}] Sending "report-status" aknowledgement.""", lid)
  +                    match Msg(config.["ckey"], "ok") |> send s with
  +                    | Error(errn, errm) -> sprintf """Error %i (send). %s.""" errn errm |> log.Error
  +                    | Msg _ -> ()
  +                //log.Trace("""[{0}] Sent "report-status" aknowledgement.""", lid)
  +                else log.Warn("""[{0}] Processing "report-status" failed (simulated).""", lid)
  +                recvloop()
  +            | "sys:client-key" -> 
  +                log.Trace("[{0}] Sending client-key: '{1}'.", lid, config.["ckey"])
  +                let encrypted = encrypt config.["publicKey"] config.["ckey"]
  +                let note = Convert.ToBase64String(encrypted)
  +                match Msg(lid.ToString(), note) |> send s with
  +                | Error(errn, errm) -> sprintf """Error %i (send). %s.""" errn errm |> log.Error
  +                | Msg _ -> log.Trace("[{0}] Sent client-key: '{1}'.", lid, config.["ckey"])
  +                recvloop()
  +            | _ -> recvloop()
  +    recvloop()
  +    assert (NN.Shutdown(s, eid) = 0)
  +    assert (NN.Close(s) = 0)
   
  -let rec private action () =
  +let rec private action() = 
       //log.Trace("[{0}] Ormonit test action enter", lid)
       match lock mlock (fun () -> continu) with
  -    | false ->
  +    | false -> 
           //log.Trace("continue value {0}", continu)
           log.Trace("[{0}] Ormonit test action exit", lid)
  -    | true ->
  +    | true -> 
           //simulate long running task 1-5s
           let t = Random().Next(1000, 5000)
           log.Trace("[{0}] Ormonit test action blocking for {1}ms", lid, t)
  
positive.code: fileTarget.ArchiveAboveSize <- 1048576L
  fileTarget.MaxArchiveFiles <- 2
  fileTarget.ArchiveDateFormat <- "yyyy-MM-dd"
  let rule1 = new NLog.Config.LoggingRule("*", LogLevel.Trace, consoleTarget)
  logConfig.LoggingRules.Add(rule1)
  let rule2 = new NLog.Config.LoggingRule("*", LogLevel.Trace, fileTarget)
  logConfig.LoggingRules.Add(rule2)
  LogManager.Configuration <- logConfig
  
  
negative.code:     lock mlock (fun () -> continu <- false)
      task.Wait()
      log.Info("[{0}] Ormonit test exit.", lid)
  