Last active
June 17, 2020 23:20
-
-
Save SLAVONchick/0de486c6586376f53d94cf5af0ce1e55 to your computer and use it in GitHub Desktop.
Revisions
-
SLAVONchick revised this gist
May 15, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ open FSharp.Control.Tasks open Pipelines.Sockets.Unofficial use client = new TcpClient("127.0.0.1", 9851) let pipe = StreamConnection.GetDuplex(client.GetStream()) let scan = Encoding.UTF8.GetBytes "*2\r\n$4\r\nSCAN\r\n$36\r\n85AB427D-316C-4BD4-A511-6631851D212E\r\n" |> ReadOnlyMemory task { let! _ = pipe.Output.WriteAsync(scan) -
SLAVONchick created this gist
May 15, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ open System open System.Net open FSharp.Control.Tasks open Pipelines.Sockets.Unofficial use client = new TcpClient("127.0.0.1", 9851) let pipe = StreamConnection.GetSuplex(client.GetStream()) let scan = Encoding.UTF8.GetBytes "*2\r\n$4\r\nSCAN\r\n$36\r\n85AB427D-316C-4BD4-A511-6631851D212E\r\n" |> ReadOnlyMemory task { let! _ = pipe.Output.WriteAsync(scan) let mutable isCompleted = false while not isCompleted do let! res = pipe.Input.ReadAsync() for segment in res.Buffer do printfn "%s" <| Encoding.UTF8.GetString segment.Span pipe.Input.AdvanceTo(res.Buffer.Start, res.Buffer.End) isCompleted <- res.IsCompleted do! pipe.Input.CompleteAsync() } |> Async.AwaitTask |> Async.RunSynchronously